From 148138cafcd6579eb117911cc2cd372a188dd07c Mon Sep 17 00:00:00 2001 From: Tlakollo Date: Tue, 30 Aug 2022 09:52:13 -0700 Subject: [PATCH 01/11] Run codeanalysis analyzers in the coreclr/tools directory --- .../Common/CommandLine/ArgumentParser.cs | 2 +- .../Common/CommandLine/ArgumentSyntax.cs | 34 +- .../CommandLine/ArgumentSyntax_Definers.cs | 2 +- .../tools/Common/CommandLine/ArgumentToken.cs | 4 +- .../CommandLine/CommandLineException.cs | 2 +- .../Common/CommandLine/CommandLineHelpers.cs | 6 +- .../Common/CommandLine/HelpTextGenerator.cs | 8 +- .../Compiler/CodeGenerationFailedException.cs | 2 +- .../CompilerTypeSystemContext.Validation.cs | 4 +- .../Compiler/CompilerTypeSystemContext.cs | 28 +- .../DependencyAnalysis/CompilerComparer.cs | 1 - .../EmbeddedDataContainerNode.cs | 4 +- .../INodeWithRuntimeDeterminedDependencies.cs | 3 +- .../DependencyAnalysis/ISymbolNode.cs | 5 +- .../MethodReadOnlyDataNode.cs | 2 - .../ObjectAndOffsetSymbolNode.cs | 2 +- .../DependencyAnalysis/ObjectDataBuilder.cs | 8 +- .../Compiler/DependencyAnalysis/ObjectNode.cs | 4 +- .../DependencyAnalysis/ObjectNodeSection.cs | 4 +- .../ShadowConcreteMethodNode.cs | 2 +- .../SortableDependencyNode.cs | 3 +- .../Target_ARM/ARMEmitter.cs | 3 +- .../DependencyAnalysis/Target_ARM/Register.cs | 8 +- .../Target_ARM/TargetRegisterMap.cs | 2 - .../Target_ARM64/ARM64Emitter.cs | 4 +- .../Target_ARM64/AddrMode.cs | 2 - .../Target_ARM64/Register.cs | 10 +- .../Target_ARM64/TargetRegisterMap.cs | 2 - .../Target_LoongArch64/AddrMode.cs | 2 - .../Target_LoongArch64/Register.cs | 6 - .../Target_LoongArch64/TargetRegisterMap.cs | 2 - .../DependencyAnalysis/Target_X64/AddrMode.cs | 2 - .../DependencyAnalysis/Target_X64/Register.cs | 6 - .../Target_X64/X64Emitter.cs | 9 +- .../DependencyAnalysis/Target_X86/AddrMode.cs | 2 - .../DependencyAnalysis/Target_X86/Register.cs | 8 +- .../Target_X86/TargetRegisterMap.cs | 2 +- .../Target_X86/X86Emitter.cs | 9 +- .../Compiler/DevirtualizationManager.cs | 3 +- .../Common/Compiler/DisplayNameHelpers.cs | 8 +- .../Compiler/HardwareIntrinsicHelpers.cs | 5 - .../Common/Compiler/InstructionSetSupport.cs | 5 +- .../tools/Common/Compiler/MethodExtensions.cs | 3 - .../Common/Compiler/NativeAotNameMangler.cs | 39 +- .../tools/Common/Compiler/TypeExtensions.cs | 10 +- .../Compiler/VectorFieldLayoutAlgorithm.cs | 6 +- .../LowLevelLinq/LowLevelEnumerable.ToList.cs | 2 - .../Metadata/NativeFormat/MdBinaryReader.cs | 7 - .../NativeFormat/MdBinaryReaderGen.cs | 4 - .../NativeFormat/NativeFormatReaderGen.cs | 2 +- .../NativeFormat/NativeMetadataReader.cs | 4 +- .../NativeFormatReader.Primitives.cs | 2 - .../NativeFormat/NativeFormatReader.String.cs | 1 - .../NativeFormat/NativeFormatReader.cs | 3 +- .../NativeFormat/NativeFormatWriter.cs | 127 +- .../Common/Internal/Runtime/CorConstants.cs | 2 - .../Internal/Runtime/EETypeBuilderHelpers.cs | 3 +- .../Runtime/EETypeOptionalFieldsBuilder.cs | 16 +- .../Common/Internal/Runtime/GCDescEncoder.cs | 2 +- .../InterfaceDispatchCellCachePointerFlags.cs | 2 - .../Common/Internal/Runtime/ModuleHeaders.cs | 3 +- .../Internal/Runtime/ReadyToRunConstants.cs | 2 +- .../UniversalGenericParameterLayout.cs | 15 +- .../tools/Common/Internal/Text/Utf8String.cs | 3 +- .../Common/Internal/Text/Utf8StringBuilder.cs | 4 +- .../tools/Common/JitInterface/CorInfoBase.cs | 356 +++--- .../Common/JitInterface/CorInfoHelpFunc.cs | 18 +- .../tools/Common/JitInterface/CorInfoImpl.cs | 158 ++- .../JitInterface/CorInfoInstructionSet.cs | 10 +- .../JitInterface/CorInfoTypes.VarInfo.cs | 1 - .../tools/Common/JitInterface/CorInfoTypes.cs | 11 +- .../Common/JitInterface/JitConfigProvider.cs | 7 +- .../LoongArch64PassStructInRegister.cs | 9 +- .../tools/Common/JitInterface/MemoryHelper.cs | 2 - .../SystemVStructClassificator.cs | 14 +- .../tools/Common/JitInterface/TypeString.cs | 6 +- .../Common/JitInterface/UnboxingMethodDesc.cs | 3 +- .../JitInterface/UnboxingMethodDescFactory.cs | 4 +- src/coreclr/tools/Common/Pgo/PgoFormat.cs | 30 +- .../Common/Pgo/TypeSystemEntityOrUnknown.cs | 4 +- .../Sorting/ISortableDataStructureAccessor.cs | 4 - .../tools/Common/Sorting/ListAccessor.cs | 1 - src/coreclr/tools/Common/Sorting/MergeSort.cs | 2 +- .../tools/Common/Sorting/MergeSortCore.cs | 5 +- .../TypeSystem/Canon/ArrayType.Canon.cs | 4 +- .../TypeSystem/Canon/ByRefType.Canon.cs | 2 +- .../TypeSystem/Canon/CanonTypes.Diagnostic.cs | 7 - .../TypeSystem/Canon/CanonTypes.Interop.cs | 2 +- .../TypeSystem/Canon/CanonTypes.Sorting.cs | 6 +- .../Common/TypeSystem/Canon/DefType.Canon.cs | 2 +- .../Canon/FunctionPointerType.Canon.cs | 4 +- .../Canon/InstantiatedMethod.Canon.cs | 10 +- .../Canon/InstantiatedType.Canon.cs | 2 +- .../TypeSystem/Canon/MetadataType.Canon.cs | 2 +- .../TypeSystem/Canon/MethodDelegator.Canon.cs | 2 +- .../TypeSystem/Canon/MethodDesc.Canon.cs | 2 +- .../Canon/MethodForInstantiatedType.Canon.cs | 2 +- .../Canon/ParameterizedType.Canon.cs | 2 +- .../TypeSystem/Canon/PointerType.Canon.cs | 2 +- .../Canon/SignatureVariable.Canon.cs | 4 +- .../Common/TypeSystem/Canon/TypeDesc.Canon.cs | 11 +- .../TypeSystem/CodeGen/FieldDesc.CodeGen.cs | 4 +- .../CodeGen/MethodDelegator.CodeGen.cs | 2 +- .../CodeGen/NativeStructType.CodeGen.cs | 2 +- .../CodeGen/TargetDetails.CodeGen.cs | 2 +- .../TypeSystem/CodeGen/TypeDesc.CodeGen.cs | 4 +- .../ArrayOfTRuntimeInterfacesAlgorithm.cs | 1 - .../Common/TypeSystem/Common/ArrayType.cs | 1 - .../BaseTypeRuntimeInterfacesAlgorithm.cs | 3 - .../Common/TypeSystem/Common/CastingHelper.cs | 4 +- .../Common/ConstructedTypeRewritingHelpers.cs | 1 - .../TypeSystem/Common/DefType.Diagnostic.cs | 4 +- .../TypeSystem/Common/DefType.FieldLayout.cs | 18 +- .../Common/FieldDesc.FieldLayout.cs | 1 - .../TypeSystem/Common/FieldDesc.ToString.cs | 2 +- .../Common/TypeSystem/Common/FieldDesc.cs | 5 +- .../Common/FieldForInstantiatedType.cs | 4 +- .../TypeSystem/Common/FunctionPointerType.cs | 2 - .../Common/GenericParameterDesc.Diagnostic.cs | 1 - .../TypeSystem/Common/GenericParameterDesc.cs | 2 +- .../TypeSystem/Common/InstantiatedMethod.cs | 4 +- .../Common/InstantiatedType.Interfaces.cs | 5 +- .../Common/InstantiatedType.MethodImpls.cs | 4 +- .../TypeSystem/Common/InstantiatedType.cs | 4 +- .../Common/TypeSystem/Common/LayoutInt.cs | 2 +- .../Common/TypeSystem/Common/LinqPoison.cs | 2 +- .../Common/MetadataFieldLayoutAlgorithm.cs | 19 +- .../MetadataRuntimeInterfacesAlgorithm.cs | 9 +- .../Common/MetadataType.Interfaces.cs | 3 - .../Common/MetadataType.MethodImpls.cs | 2 - .../Common/MetadataTypeSystemContext.cs | 1 - .../Common/MetadataVirtualMethodAlgorithm.cs | 16 +- .../Common/MethodDelegator.Diagnostic.cs | 2 +- .../Common/MethodDesc.Diagnostic.cs | 4 +- .../TypeSystem/Common/MethodDesc.ToString.cs | 4 +- .../Common/TypeSystem/Common/MethodDesc.cs | 6 +- .../Common/MethodForInstantiatedType.cs | 4 +- .../Common/TypeSystem/Common/ModuleDesc.cs | 1 - .../TypeSystem/Common/ParameterizedType.cs | 2 - .../TypeSystem/Common/SignatureVariable.cs | 4 - .../TypeSystem/Common/TargetArchitecture.cs | 3 - .../Common/TargetDetails.ToString.cs | 5 +- .../TypeSystem/Common/ThrowHelper.Common.cs | 1 - .../TypeSystem/Common/TypeDesc.Interfaces.cs | 1 - .../TypeSystem/Common/TypeDesc.ToString.cs | 2 +- .../Common/TypeSystem/Common/TypeDesc.cs | 12 +- .../Common/TypeHashingAlgorithms.cs | 1 - .../Common/TypeSystemConstraintsHelpers.cs | 2 +- .../TypeSystem/Common/TypeSystemContext.cs | 12 +- .../Common/TypeSystemException.Resources.cs | 3 +- .../TypeSystem/Common/TypeSystemException.cs | 6 +- .../TypeSystem/Common/TypeSystemHelpers.cs | 2 +- .../Common/UniversalCanonLayoutAlgorithm.cs | 4 - .../CustomAttributeTypeNameFormatter.cs | 2 +- .../CustomAttributeTypeNameParser.cs | 28 +- .../Common/Utilities/DebugNameFormatter.cs | 2 - .../ExceptionTypeNameFormatter.Metadata.cs | 6 +- .../Utilities/GCPointerMap.Algorithm.cs | 2 +- .../Common/Utilities/GCPointerMap.cs | 2 +- .../Utilities/LockFreeReaderHashtable.cs | 5 +- .../Common/Utilities/TypeNameFormatter.cs | 1 - .../Common/TypeSystem/Common/WellKnownType.cs | 2 - .../Ecma/CachingMetadataStringDecoder.cs | 4 +- .../TypeSystem/Ecma/EcmaAssembly.Symbols.cs | 2 +- .../TypeSystem/Ecma/EcmaField.CodeGen.cs | 2 +- .../Ecma/EcmaField.Serialization.cs | 2 +- .../TypeSystem/Ecma/EcmaField.Sorting.cs | 2 +- .../Ecma/EcmaGenericParameter.Sorting.cs | 2 +- .../TypeSystem/Ecma/EcmaGenericParameter.cs | 6 +- .../TypeSystem/Ecma/EcmaMethod.Sorting.cs | 2 +- .../Common/TypeSystem/Ecma/EcmaMethod.cs | 4 +- .../TypeSystem/Ecma/EcmaModule.Sorting.cs | 2 +- .../TypeSystem/Ecma/EcmaModule.Symbols.cs | 2 +- .../Common/TypeSystem/Ecma/EcmaModule.cs | 44 +- .../TypeSystem/Ecma/EcmaSignatureEncoder.cs | 5 +- .../TypeSystem/Ecma/EcmaSignatureParser.cs | 38 +- .../Ecma/EcmaSignatureTranslator.cs | 21 +- .../TypeSystem/Ecma/EcmaType.Diagnostic.cs | 7 - .../TypeSystem/Ecma/EcmaType.Interfaces.cs | 6 - .../TypeSystem/Ecma/EcmaType.MethodImpls.cs | 13 +- .../TypeSystem/Ecma/EcmaType.Serialization.cs | 2 +- .../TypeSystem/Ecma/EcmaType.Sorting.cs | 2 +- .../tools/Common/TypeSystem/Ecma/EcmaType.cs | 3 +- .../Common/TypeSystem/Ecma/IEcmaModule.cs | 7 +- .../Ecma/IMetadataStringDecoderProvider.cs | 1 - .../TypeSystem/Ecma/MetadataExtensions.cs | 8 +- .../SymbolReader/PortablePdbSymbolReader.cs | 4 +- .../SymbolReader/UnmanagedPdbSymbolReader.cs | 58 +- .../Common/TypeSystem/IL/DelegateInfo.cs | 5 +- .../TypeSystem/IL/EcmaMethodIL.Symbols.cs | 2 +- .../Common/TypeSystem/IL/HelperExtensions.cs | 10 +- .../Common/TypeSystem/IL/ILDisassembler.cs | 17 +- .../tools/Common/TypeSystem/IL/ILImporter.cs | 13 +- .../tools/Common/TypeSystem/IL/ILOpcode.cs | 2 - .../tools/Common/TypeSystem/IL/ILReader.cs | 9 +- .../Common/TypeSystem/IL/ILStackHelper.cs | 4 +- .../Common/TypeSystem/IL/ILTokenReplacer.cs | 2 +- .../TypeSystem/IL/InstantiatedMethodIL.cs | 13 +- .../Common/TypeSystem/IL/MethodIL.Symbols.cs | 6 +- .../tools/Common/TypeSystem/IL/MethodIL.cs | 8 +- .../Common/TypeSystem/IL/MethodILDebugView.cs | 14 +- .../TypeSystem/IL/NativeAotILProvider.cs | 6 +- .../IL/Stubs/ArrayMethodILEmitter.cs | 2 +- ...GetExecutingAssemblyMethodThunk.Sorting.cs | 2 +- ...AssemblyGetExecutingAssemblyMethodThunk.cs | 6 +- .../CalliMarshallingMethodThunk.Mangling.cs | 1 - .../CalliMarshallingMethodThunk.Sorting.cs | 2 +- .../IL/Stubs/CalliMarshallingMethodThunk.cs | 4 - .../TypeSystem/IL/Stubs/ComparerIntrinsics.cs | 7 +- ...DelegateMarshallingMethodThunk.Mangling.cs | 1 - .../DelegateMarshallingMethodThunk.Sorting.cs | 2 +- .../Stubs/DelegateMarshallingMethodThunk.cs | 10 +- .../IL/Stubs/DelegateThunks.Sorting.cs | 14 +- .../TypeSystem/IL/Stubs/DelegateThunks.cs | 6 +- .../DynamicInvokeMethodThunk.Mangling.cs | 1 - .../Stubs/DynamicInvokeMethodThunk.Sorting.cs | 5 +- .../IL/Stubs/DynamicInvokeMethodThunk.cs | 6 - .../TypeSystem/IL/Stubs/EnumThunks.Sorting.cs | 4 +- .../Common/TypeSystem/IL/Stubs/EnumThunks.cs | 4 +- .../ForwardDelegateCreationThunk.Sorting.cs | 2 +- .../IL/Stubs/ForwardDelegateCreationThunk.cs | 20 +- .../IL/Stubs/GetCanonTypeIntrinsic.cs | 2 - .../Common/TypeSystem/IL/Stubs/ILEmitter.cs | 21 +- .../IL/Stubs/InterlockedIntrinsics.cs | 1 - .../IL/Stubs/MemoryMarshalIntrinsics.cs | 3 +- ...ethodBaseGetCurrentMethodThunk.Mangling.cs | 2 +- ...MethodBaseGetCurrentMethodThunk.Sorting.cs | 2 +- .../Stubs/MethodBaseGetCurrentMethodThunk.cs | 6 +- .../IL/Stubs/PInvokeILCodeStreams.cs | 4 +- .../TypeSystem/IL/Stubs/PInvokeILEmitter.cs | 2 +- .../IL/Stubs/PInvokeLazyFixupField.Sorting.cs | 2 +- .../PInvokeTargetNativeMethod.Diagnostic.cs | 4 +- .../PInvokeTargetNativeMethod.Mangling.cs | 2 +- .../PInvokeTargetNativeMethod.Sorting.cs | 2 +- .../IL/Stubs/PInvokeTargetNativeMethod.cs | 2 +- .../IL/Stubs/RuntimeHelpersIntrinsics.cs | 1 - .../TypeSystem/IL/Stubs/StreamIntrinsics.cs | 2 - .../Stubs/StructMarshallingThunk.Sorting.cs | 2 +- .../IL/Stubs/StructMarshallingThunk.cs | 20 +- .../Stubs/TypeGetTypeMethodThunk.Sorting.cs | 2 +- .../IL/Stubs/TypeGetTypeMethodThunk.cs | 6 +- .../TypeSystem/IL/Stubs/UnsafeIntrinsics.cs | 2 +- ...ypeGetFieldHelperMethodOverride.Sorting.cs | 2 +- .../ValueTypeGetFieldHelperMethodOverride.cs | 4 +- .../TypeSystem/Interop/FieldDesc.Interop.cs | 4 +- .../Interop/IL/InlineArrayType.Sorting.cs | 6 +- .../TypeSystem/Interop/IL/InlineArrayType.cs | 15 +- .../Interop/IL/MarshalHelpers.Aot.cs | 6 +- .../TypeSystem/Interop/IL/MarshalHelpers.cs | 2 - .../TypeSystem/Interop/IL/MarshalUtils.cs | 2 - .../TypeSystem/Interop/IL/Marshaller.Aot.cs | 49 +- .../TypeSystem/Interop/IL/Marshaller.cs | 54 +- .../TypeSystem/Interop/IL/MarshallerKind.cs | 2 +- .../Interop/IL/NativeStructType.Mangling.cs | 2 +- .../Interop/IL/NativeStructType.Sorting.cs | 4 +- .../TypeSystem/Interop/IL/NativeStructType.cs | 3 +- .../IL/PInvokeDelegateWrapper.Mangling.cs | 2 +- .../IL/PInvokeDelegateWrapper.Sorting.cs | 2 +- .../Interop/IL/PInvokeDelegateWrapper.cs | 5 +- ...nvokeDelegateWrapperConstructor.Sorting.cs | 2 +- .../IL/PInvokeDelegateWrapperConstructor.cs | 9 +- .../TypeSystem/Interop/InteropStateManager.cs | 41 +- .../Common/TypeSystem/Interop/InteropTypes.cs | 2 - .../TypeSystem/Interop/MarshalAsDescriptor.cs | 2 - .../Interop/MetadataType.Interop.cs | 2 - .../Interop/MethodDelegator.Interop.cs | 2 +- .../TypeSystem/Interop/MethodDesc.Interop.cs | 6 +- .../TypeSystemMetadataEmitter.cs | 54 +- .../ArrayType.RuntimeDetermined.cs | 4 +- .../ByRefType.RuntimeDetermined.cs | 2 +- .../DefType.RuntimeDetermined.cs | 2 +- .../FieldDesc.RuntimeDetermined.cs | 2 +- .../FunctionPointerType.RuntimeDetermined.cs | 2 +- .../GenericParameterDesc.RuntimeDetermined.cs | 2 +- .../MethodDesc.RuntimeDetermined.cs | 4 +- ...thodForRuntimeDeterminedType.Diagnostic.cs | 2 +- .../MethodForRuntimeDeterminedType.Sorting.cs | 2 +- .../MethodForRuntimeDeterminedType.cs | 1 - .../ParameterizedType.RuntimeDetermined.cs | 2 +- .../PointerType.RuntimeDetermined.cs | 2 +- ...timeDeterminedCanonicalizationAlgorithm.cs | 2 +- .../RuntimeDeterminedFieldLayoutAlgorithm.cs | 5 +- .../RuntimeDeterminedType.Diagnostic.cs | 6 +- .../RuntimeDeterminedType.Sorting.cs | 2 +- .../RuntimeDeterminedType.cs | 7 +- .../SignatureVariable.RuntimeDetermined.cs | 2 +- .../TypeDesc.RuntimeDetermined.cs | 2 +- .../TypeSystemContext.RuntimeDetermined.cs | 6 +- .../Serialization/FieldDesc.Serialization.cs | 4 +- .../Serialization/TypeDesc.Serialization.cs | 4 +- .../TypeSystem/Sorting/ArrayType.Sorting.cs | 4 +- .../TypeSystem/Sorting/ByRefType.Sorting.cs | 2 +- .../TypeSystem/Sorting/FieldDesc.Sorting.cs | 2 +- .../FieldForInstantiatedType.Sorting.cs | 2 +- .../Sorting/FunctionPointerType.Sorting.cs | 2 +- .../Sorting/InstantiatedMethod.Sorting.cs | 6 +- .../Sorting/InstantiatedType.Sorting.cs | 8 +- .../TypeSystem/Sorting/MethodDesc.Sorting.cs | 2 +- .../MethodForInstantiatedType.Sorting.cs | 2 +- .../Sorting/MethodSignature.Sorting.cs | 2 +- .../TypeSystem/Sorting/PointerType.Sorting.cs | 2 +- .../Sorting/SignatureVariable.Sorting.cs | 8 +- .../TypeSystem/Sorting/TypeDesc.Sorting.cs | 2 +- .../TypeSystem/Sorting/TypeSystemComparer.cs | 1 - src/coreclr/tools/aot/.editorconfig | 15 + .../Compiler/AnalysisBasedMetadataManager.cs | 4 +- .../BlockedInternalsBlockingPolicy.cs | 20 +- .../Compiler/BodySubstitution.cs | 6 +- .../Compiler/BodySubstitutionParser.cs | 8 +- .../Compiler/Compilation.cs | 19 +- .../Compiler/CompilationBuilder.Aot.cs | 4 +- .../Compiler/CompilationModuleGroup.Aot.cs | 6 +- .../CompilerGeneratedInteropStubManager.cs | 2 +- .../CompilerMetadataFieldLayoutAlgorithm.cs | 5 +- .../Compiler/CompilerTypeSystemContext.Aot.cs | 7 +- .../CompilerTypeSystemContext.BoxedTypes.cs | 41 +- .../CompilerTypeSystemContext.DelegateInfo.cs | 10 +- ...CompilerTypeSystemContext.DynamicInvoke.cs | 9 +- .../CompilerTypeSystemContext.EnumMethods.cs | 9 +- ...SystemContext.GeneratedAssembly.Sorting.cs | 4 +- ...ilerTypeSystemContext.GeneratedAssembly.cs | 4 +- ...mpilerTypeSystemContext.InterfaceThunks.cs | 14 +- .../CompilerTypeSystemContext.Mangling.cs | 9 +- .../CompilerTypeSystemContext.Sorting.cs | 14 +- ...pilerTypeSystemContext.ValueTypeMethods.cs | 11 +- .../Compiler/Dataflow/ArrayValue.cs | 10 +- .../Compiler/Dataflow/AttributeDataFlow.cs | 14 +- .../Dataflow/CompilerGeneratedCallGraph.cs | 7 +- .../Dataflow/CompilerGeneratedNames.cs | 2 +- .../Dataflow/CompilerGeneratedState.cs | 26 +- .../Compiler/Dataflow/DiagnosticContext.cs | 10 +- .../Compiler/Dataflow/DiagnosticUtilities.cs | 6 +- .../Compiler/Dataflow/EcmaExtensions.cs | 2 +- .../Compiler/Dataflow/FieldValue.cs | 2 +- .../Compiler/Dataflow/FlowAnnotations.cs | 33 +- .../Dataflow/GenericArgumentDataFlow.cs | 10 +- .../Dataflow/GenericParameterValue.cs | 2 +- .../Compiler/Dataflow/HandleCallAction.cs | 8 +- .../Compiler/Dataflow/HoistedLocalKey.cs | 2 +- .../Compiler/Dataflow/IValueWithStaticType.cs | 2 +- .../Compiler/Dataflow/InterproceduralState.cs | 14 +- .../Compiler/Dataflow/MethodBodyScanner.cs | 43 +- .../Compiler/Dataflow/MethodParameterValue.cs | 2 +- .../Compiler/Dataflow/MethodProxy.cs | 2 +- .../Compiler/Dataflow/MethodReturnValue.cs | 2 +- .../Dataflow/MethodThisParameterValue.cs | 2 +- .../Compiler/Dataflow/Origin.cs | 13 +- .../Compiler/Dataflow/ReflectionMarker.cs | 9 +- .../Dataflow/ReflectionMethodBodyScanner.cs | 19 +- ...RequireDynamicallyAccessedMembersAction.cs | 6 +- .../Compiler/Dataflow/ScannerExtensions.cs | 4 - .../Dataflow/TrimAnalysisPatternStore.cs | 8 +- .../Compiler/Dataflow/TypeExtensions.cs | 4 +- .../Compiler/Dataflow/ValueNode.cs | 2 +- .../ArrayOfEmbeddedDataNode.cs | 7 +- .../ArrayOfEmbeddedPointersNode.cs | 6 +- .../ArrayOfFrozenObjectsNode.cs | 3 +- .../Compiler/DependencyAnalysis/BlobNode.cs | 1 - .../BlockReflectionTypeMapNode.cs | 4 +- .../CallingConventionConverterKey.cs | 10 +- .../CanonicalDefinitionEETypeNode.cs | 2 - .../DependencyAnalysis/CanonicalEETypeNode.cs | 10 +- .../ClassConstructorContextMap.cs | 2 +- .../CodeBasedDependencyAlgorithm.cs | 12 +- .../ConstructedEETypeNode.cs | 6 +- ...CustomAttributeBasedDependencyAlgorithm.cs | 6 +- .../CustomAttributeMetadataNode.cs | 8 +- .../DataflowAnalyzedMethodNode.cs | 3 +- .../DefaultConstructorMapNode.cs | 8 +- .../DictionaryLayoutNode.cs | 14 +- .../DynamicDependencyAttributeAlgorithm.cs | 5 +- .../Compiler/DependencyAnalysis/EETypeNode.cs | 24 +- .../EETypeOptionalFieldsNode.cs | 8 +- .../EmbeddedPointerIndirectionNode.cs | 1 - .../EmbeddedTrimmingDescriptorNode.cs | 4 +- .../ExactMethodInstantiationsNode.cs | 2 +- .../DependencyAnalysis/ExternSymbolNode.cs | 5 +- .../ExternSymbolsImportedNodeProvider.cs | 4 - .../ExternalReferencesTableNode.cs | 6 +- .../FatFunctionPointerNode.cs | 2 +- .../DependencyAnalysis/FieldMetadataNode.cs | 2 +- .../DependencyAnalysis/FieldRvaDataNode.cs | 2 +- .../DependencyAnalysis/FrozenObjectNode.cs | 2 +- .../DependencyAnalysis/GCStaticEETypeNode.cs | 1 - .../DependencyAnalysis/GCStaticsNode.cs | 4 +- .../GCStaticsPreInitDataNode.cs | 2 +- .../DependencyAnalysis/GVMDependenciesNode.cs | 4 +- .../GenericCompositionNode.cs | 4 +- .../GenericDefinitionEETypeNode.cs | 3 +- .../GenericDictionaryNode.cs | 4 +- .../DependencyAnalysis/GenericLookupResult.cs | 13 +- .../GenericMethodsHashtableNode.cs | 4 +- .../GenericMethodsTemplateMap.cs | 2 +- .../GenericTypesTemplateMap.cs | 5 +- .../DependencyAnalysis/ILScanNodeFactory.cs | 2 - .../INodeWithCodeInfo.Aot.cs | 2 - .../DependencyAnalysis/INodeWithDebugInfo.cs | 2 +- .../ISpecialUnboxThunkNode.cs | 2 - .../ImportedNodeProvider.cs | 4 - .../IndirectionExtensions.cs | 7 +- .../InterfaceDispatchCellNode.cs | 4 +- .../InterfaceDispatchCellSectionNode.cs | 4 +- .../InterfaceDispatchMapNode.cs | 8 +- .../InterfaceGenericVirtualMethodTableNode.cs | 14 +- .../DependencyAnalysis/JumpStubNode.cs | 2 +- .../DependencyAnalysis/MetadataNode.cs | 3 +- .../MethodAssociatedDataNode.cs | 1 - .../MethodExceptionHandlingInfoNode.cs | 2 - .../DependencyAnalysis/MethodMetadataNode.cs | 2 +- .../ModuleInitializerListNode.cs | 12 +- .../DependencyAnalysis/ModuleMetadataNode.cs | 2 +- .../ModuleUseBasedDependencyAlgorithm.cs | 2 +- .../DependencyAnalysis/ModulesSectionNode.cs | 2 - .../NativeLayoutInfoNode.cs | 1 - .../NativeLayoutVertexNode.cs | 146 ++- .../NecessaryCanonicalEETypeNode.cs | 1 - .../NodeFactory.GenericLookups.cs | 4 +- .../NodeFactory.NativeLayout.cs | 7 +- .../DependencyAnalysis/NodeFactory.cs | 22 +- .../DependencyAnalysis/NonGCStaticsNode.cs | 3 +- .../ObjectGetTypeFlowDependenciesNode.cs | 8 +- .../DependencyAnalysis/ObjectWriter.cs | 39 +- .../PInvokeMethodFixupNode.cs | 2 +- .../ReadyToRunGenericHelperNode.cs | 6 +- .../ReadyToRunHeaderNode.cs | 15 +- .../ReadyToRunHelperNode.cs | 12 +- .../ReflectableFieldNode.cs | 1 - .../ReflectableMethodNode.cs | 1 - .../ReflectionFieldMapNode.cs | 3 +- .../ReflectionInvokeMapNode.cs | 3 +- .../ReflectionMethodBodyScanner.cs | 8 +- .../ReflectionVirtualInvokeMapNode.cs | 19 +- .../DependencyAnalysis/ResourceDataNode.cs | 9 +- .../DependencyAnalysis/ResourceIndexNode.cs | 5 +- .../RuntimeFieldHandleNode.cs | 1 - .../RuntimeMethodHandleNode.cs | 3 +- .../DependencyAnalysis/ScannedMethodNode.cs | 2 +- .../DependencyAnalysis/SealedVTableNode.cs | 7 +- .../ShadowConcreteUnboxingThunkNode.cs | 4 +- .../StackTraceMethodMappingNode.cs | 1 - .../StaticsInfoHashtableNode.cs | 5 +- .../StringAllocatorMethodNode.cs | 2 +- .../DependencyAnalysis/Target_ARM/ARMDebug.cs | 3 +- .../ARMInitialInterfaceDispatchStubNode.cs | 2 +- .../Target_ARM/ARMNodeFactory.cs | 7 +- .../ARMReadyToRunGenericHelperNode.cs | 4 +- .../Target_ARM/ARMReadyToRunHelperNode.cs | 4 +- .../Target_ARM/ARMUnboxingStubNode.cs | 2 +- .../ARM64ReadyToRunGenericHelperNode.cs | 4 +- .../Target_ARM64/ARM64ReadyToRunHelperNode.cs | 2 +- .../Target_ARM64/ARM64UnboxingStubNode.cs | 3 +- .../LoongArch64ReadyToRunGenericHelperNode.cs | 4 +- .../LoongArch64UnboxingStubNode.cs | 1 - .../X64ReadyToRunGenericHelperNode.cs | 6 +- .../X86ReadyToRunGenericHelperNode.cs | 14 +- .../TentativeInstanceMethodNode.cs | 5 - .../DependencyAnalysis/TentativeMethodNode.cs | 2 +- .../DependencyAnalysis/ThreadStaticsNode.cs | 2 +- .../TrimmingDescriptorNode.cs | 4 - .../DependencyAnalysis/TypeGVMEntriesNode.cs | 7 +- .../TypeManagerIndirectionNode.cs | 3 - .../DependencyAnalysis/TypeMetadataMapNode.cs | 3 +- .../DependencyAnalysis/TypeMetadataNode.cs | 7 +- .../DependencyAnalysis/UnboxingStubNode.cs | 8 +- .../DependencyAnalysis/VTableSliceNode.cs | 8 +- .../VariantInterfaceMethodUseNode.cs | 5 +- .../VirtualMethodUseNode.cs | 7 +- .../Compiler/DescriptorMarker.cs | 36 +- .../Compiler/Disassembler.cs | 2 +- .../Compiler/EmptyInteropStubManager.cs | 2 - .../Compiler/FeatureSettings.cs | 5 +- .../Compiler/FeatureSwitchManager.cs | 17 +- .../Compiler/GeneratingMetadataManager.cs | 8 +- .../Compiler/GenericDictionaryLookup.cs | 2 +- .../Compiler/GenericRootProvider.cs | 2 - ...semblyGeneratingMethodDebugInfoProvider.cs | 4 +- .../ILCompiler.Compiler/Compiler/ILScanner.cs | 15 +- .../Compiler/ILScannerBuilder.cs | 2 - .../Compiler/ILStreamReader.cs | 2 +- .../Compiler/ILogWriter.cs | 2 - .../Compiler/InteropStubManager.cs | 2 - .../ILCompiler.Compiler/Compiler/JitHelper.cs | 2 +- .../Compiler/LazyGenerics/Graph.Cycles.cs | 35 +- .../Compiler/LazyGenerics/Graph.Vertex.cs | 10 +- .../Compiler/LazyGenerics/Graph.cs | 3 +- .../LazyGenerics/GraphBuilder.ForEach.cs | 9 +- .../LazyGenerics/GraphBuilder.MethodCall.cs | 3 +- .../Compiler/LazyGenerics/GraphBuilder.cs | 2 +- .../Compiler/LazyGenerics/ModuleCycleInfo.cs | 8 +- .../Compiler/LibraryRootProvider.cs | 9 +- .../ILCompiler.Compiler/Compiler/Logger.cs | 10 +- ...mentationSignatureGenerator.PartVisitor.cs | 5 +- .../Logging/DocumentationSignatureParser.cs | 53 +- .../Compiler/Logging/MessageContainer.cs | 12 +- .../Compiler/Logging/MessageOrigin.cs | 7 +- .../ManifestResourceBlockingPolicy.cs | 6 +- .../Compiler/MetadataManager.cs | 3 +- .../Compiler/MstatObjectDumper.cs | 3 +- .../MultiFileCompilationModuleGroup.cs | 3 +- .../NativeLibraryInitializerRootProvider.cs | 2 - .../Compiler/NodeMangler.cs | 3 +- .../Compiler/ObjectDumper.cs | 7 +- .../Compiler/PreinitializationManager.cs | 8 +- .../Compiler/ProcessLinkerXmlBase.cs | 62 +- .../Compiler/ProcessXmlBase.cs | 20 +- .../Compiler/RootingHelpers.cs | 3 - .../Compiler/RootingServiceProvider.cs | 2 +- .../RuntimeConfigurationRootProvider.cs | 2 +- .../Compiler/TextLogWriter.cs | 3 +- .../Compiler/TypePreinit.cs | 26 +- .../Compiler/UniversalGenericsRootProvider.cs | 2 +- .../Compiler/UnixNodeMangler.cs | 1 - .../Compiler/UsageBasedInteropStubManager.cs | 10 +- .../Compiler/UsageBasedMetadataManager.cs | 33 +- .../Compiler/UserDefinedTypeDescriptor.cs | 58 +- .../Compiler/VectorOfTFieldLayoutAlgorithm.cs | 2 +- .../Compiler/VirtualMethodCallHelper.cs | 5 +- .../Compiler/WindowsNodeMangler.cs | 3 +- .../Compiler/XmlObjectDumper.cs | 2 +- .../IL/ILImporter.Scanner.cs | 106 +- .../IL/Stubs/PInvokeILProvider.cs | 2 - .../AppContextInitializerMethod.Sorting.cs | 2 +- .../AppContextInitializerMethod.cs | 5 +- .../NativeLibraryStartupMethod.Sorting.cs | 5 +- .../StartupCode/NativeLibraryStartupMethod.cs | 8 +- .../StartupCodeMainMethod.Sorting.cs | 9 +- .../StartupCode/StartupCodeMainMethod.cs | 9 +- .../ILCompiler.Compiler.csproj | 1 + .../ComputedStaticDependencyNode.cs | 3 - .../DependencyAnalyzer.cs | 41 +- .../DependencyAnalyzerBase.cs | 7 +- .../DependencyNode.cs | 3 +- .../DependencyNodeCore.cs | 11 +- .../DgmlWriter.cs | 6 +- .../EventSourceLogStrategy.cs | 21 +- .../FirstMarkLogStrategy.cs | 10 +- .../FullGraphLogStrategy.cs | 8 +- .../IDependencyAnalysisMarkStrategy.cs | 1 - .../IDependencyAnalyzerLogEdgeVisitor.cs | 6 - .../IDependencyNode.cs | 2 +- ...ompiler.DependencyAnalysisFramework.csproj | 1 + .../NoLogStrategy.cs | 5 - .../PerfEventSource.cs | 4 +- .../ILCompiler.MetadataTransform.csproj | 1 + .../ILCompiler/Metadata/EntityMap.cs | 2 +- .../ILCompiler/Metadata/Transform.Constant.cs | 2 +- .../Metadata/Transform.CustomAttribute.cs | 2 +- .../ILCompiler/Metadata/Transform.Event.cs | 3 +- .../ILCompiler/Metadata/Transform.Field.cs | 4 +- .../ILCompiler/Metadata/Transform.Method.cs | 12 +- .../Metadata/Transform.Namespace.cs | 10 +- .../Metadata/Transform.Parameter.cs | 2 +- .../ILCompiler/Metadata/Transform.Property.cs | 4 +- .../ILCompiler/Metadata/Transform.Scope.cs | 6 +- .../ILCompiler/Metadata/Transform.String.cs | 2 +- .../ILCompiler/Metadata/Transform.Type.cs | 9 +- .../Metadata/Transform.TypeForwarders.cs | 6 +- .../ILCompiler/Metadata/Transform.cs | 2 +- .../NativeFormat/Writer/ConstantValues.cs | 61 +- .../NativeFormat/Writer/MdBinaryWriter.cs | 6 - .../NativeFormat/Writer/MdBinaryWriterGen.cs | 4 - .../Writer/NativeFormatWriterGen.cs | 1030 ++++++++++------- .../Writer/NativeMetadataWriter.cs | 91 +- .../Compiler/ProfileData.cs | 9 +- .../ILCompiler.ReadyToRun/IBC/IBCDataModel.cs | 2 +- .../IBC/MIbcProfileParser.cs | 33 +- .../IBC/ReaderExtensions.cs | 2 +- .../DependencyAnalysis/MethodCodeNode.cs | 12 +- .../DependencyAnalysis/RyuJitNodeFactory.cs | 2 - .../Compiler/ProfileDataManager.cs | 2 +- .../Compiler/RyuJitCompilationBuilder.cs | 7 +- .../ILCompiler.RyuJit.csproj | 1 + .../JitInterface/CorInfoImpl.RyuJit.cs | 29 +- .../ArchitectureSpecificFieldLayoutTests.cs | 5 - .../CanonicalizationTests.cs | 2 - .../CastingTests.cs | 2 +- .../ConstraintsValidationTest.cs | 2 +- .../ExceptionStringTests.cs | 2 +- .../ILCompiler.TypeSystem.Tests.csproj | 1 + .../InterfacesTests.cs | 1 - .../RuntimeDeterminedTypesTests.cs | 4 +- .../SignatureTests.cs | 5 +- ...eticVirtualOverrideTests.DiagnosticName.cs | 6 - .../TestMetadataFieldLayoutAlgorithm.cs | 3 - .../TestTypeSystemContext.cs | 24 +- .../TypeNameParsingTests.cs | 11 +- .../UniversalGenericFieldLayoutTests.cs | 10 +- .../ValueTypeShapeCharacteristicsTests.cs | 2 +- .../VirtualFunctionOverrideTests.cs | 2 +- .../ILCompiler.TypeSystem.csproj | 1 + .../ILCompiler/ConfigurablePInvokePolicy.cs | 2 +- .../tools/aot/ILCompiler/ILCompiler.csproj | 3 +- src/coreclr/tools/aot/ILCompiler/Program.cs | 32 +- .../tools/aot/ILCompiler/RdXmlRootProvider.cs | 6 +- .../tools/aot/ILLink.Shared/Annotations.cs | 4 +- .../aot/ILLink.Shared/ClosedAttribute.cs | 2 +- .../DataFlow/DefaultValueDictionary.cs | 9 +- .../DataFlow/ForwardDataFlowAnalysis.cs | 15 +- .../ILLink.Shared/DataFlow/MaybeLattice.cs | 2 +- .../aot/ILLink.Shared/DataFlow/ValueSet.cs | 16 +- .../aot/ILLink.Shared/DiagnosticString.cs | 4 +- .../tools/aot/ILLink.Shared/HashUtils.cs | 2 +- .../tools/aot/ILLink.Shared/IsExternalInit.cs | 2 +- .../ILLink.Shared/TrimAnalysis/ArrayValue.cs | 4 +- .../TrimAnalysis/ConstIntValue.cs | 2 +- .../TrimAnalysis/DiagnosticContext.cs | 2 +- .../ILLink.Shared/TrimAnalysis/FieldValue.cs | 2 +- .../TrimAnalysis/FlowAnnotations.cs | 4 +- .../TrimAnalysis/GenericParameterValue.cs | 2 +- .../TrimAnalysis/HandleCallAction.cs | 20 +- .../ILLink.Shared/TrimAnalysis/IntrinsicId.cs | 2 +- .../ILLink.Shared/TrimAnalysis/Intrinsics.cs | 2 +- .../TrimAnalysis/KnownStringValue.cs | 2 +- .../TrimAnalysis/MethodParameterValue.cs | 2 +- .../TrimAnalysis/MethodReturnValue.cs | 2 +- .../TrimAnalysis/MethodThisParameterValue.cs | 2 +- .../ILLink.Shared/TrimAnalysis/NullValue.cs | 2 +- .../TrimAnalysis/NullableSystemTypeValue.cs | 2 +- ...ableValueWithDynamicallyAccessedMembers.cs | 4 +- .../TrimAnalysis/ReferenceKind.cs | 2 +- ...RequireDynamicallyAccessedMembersAction.cs | 4 +- .../TrimAnalysis/RuntimeMethodHandleValue.cs | 2 +- ...ntimeTypeHandleForGenericParameterValue.cs | 2 +- ...imeTypeHandleForNullableSystemTypeValue.cs | 2 +- ...ableValueWithDynamicallyAccessedMembers.cs | 6 +- .../TrimAnalysis/RuntimeTypeHandleValue.cs | 2 +- .../SystemReflectionMethodBaseValue.cs | 2 +- .../TrimAnalysis/SystemTypeValue.cs | 2 +- .../TrimAnalysis/UnknownValue.cs | 2 +- .../TrimAnalysis/ValueExtensions.cs | 8 +- .../TypeSystemProxy/IMemberProxy.cs | 2 +- .../BaseExpectedLinkedBehaviorAttribute.cs | 2 +- .../BaseMemberAssertionAttribute.cs | 2 +- .../Assertions/CreatedMemberAttribute.cs | 2 +- .../Assertions/EnableLoggerAttribute.cs | 2 +- .../Assertions/ExpectBodyModifiedAttribute.cs | 2 +- ...ResolvedDocumentationSignatureAttribute.cs | 2 +- ...xpectExceptionHandlersModifiedAttribute.cs | 2 +- ...eneratedDocumentationSignatureAttribute.cs | 2 +- .../ExpectLocalsModifiedAttribute.cs | 2 +- ...ResolvedDocumentationSignatureAttribute.cs | 2 +- ...resolvedDocumentationSignatureAttribute.cs | 2 +- .../ExpectedInstructionSequenceAttribute.cs | 2 +- ...tionSequenceOnMemberInAssemblyAttribute.cs | 2 +- .../ExpectedLocalsSequenceAttribute.cs | 2 +- .../Assertions/IgnoreTestCaseAttribute.cs | 2 +- ...ptAllTypesAndMembersInAssemblyAttribute.cs | 2 +- .../Assertions/KeptAssemblyAttribute.cs | 2 +- .../Assertions/KeptAttribute.cs | 2 +- .../KeptAttributeInAssemblyAttribute.cs | 2 +- ...KeptAttributeOnFixedBufferTypeAttribute.cs | 2 +- .../KeptBaseOnTypeInAssemblyAttribute.cs | 2 +- .../Assertions/KeptBaseTypeAttribute.cs | 2 +- .../Assertions/KeptFixedBufferAttribute.cs | 2 +- .../Assertions/KeptInitializerData.cs | 2 +- .../Assertions/KeptInterfaceAttribute.cs | 2 +- .../KeptInterfaceOnTypeInAssemblyAttribute.cs | 2 +- .../Assertions/KeptMemberAttribute.cs | 2 +- .../KeptPrivateImplementationDetails.cs | 2 +- .../Assertions/KeptReferenceAttribute.cs | 2 +- .../KeptReferencesInAssemblyAttribute.cs | 2 +- .../Assertions/KeptSymbolsAttribute.cs | 2 +- .../Assertions/RemovedAssemblyAttribute.cs | 2 +- .../Assertions/RemovedAttributeInAssembly.cs | 2 +- ...movedInterfaceOnTypeInAssemblyAttribute.cs | 2 +- .../RemovedPseudoAttributeAttribute.cs | 2 +- .../Assertions/RemovedSymbolsAttribute.cs | 2 +- .../Helpers/PlatformAssemblies.cs | 2 +- .../Metadata/NotATestCaseAttribute.cs | 2 +- .../Metadata/ReferenceDependencyAttribute.cs | 2 +- .../Metadata/SandboxDependencyAttribute.cs | 2 +- .../SetupCompileAsLibraryAttribute.cs | 2 +- .../SetupCompileAssemblyNameAttribute.cs | 2 +- .../Metadata/SetupLinkerArgumentAttribute.cs | 2 +- .../SetupLinkerDefaultActionAttribute.cs | 2 +- .../SetupLinkerKeepDebugMembersAttribute.cs | 2 +- ...SetupLinkerLinkPublicAndFamilyAttribute.cs | 2 +- .../SetupLinkerResponseFileAttribute.cs | 2 +- .../SetupLinkerSubstitutionFileAttribute.cs | 2 +- ...ono.Linker.Tests.Cases.Expectations.csproj | 1 + .../RemoveAttributeInstancesAttribute.cs | 2 +- .../Mono.Linker.Tests.Cases.csproj | 1 + .../Extensions/CecilExtensions.cs | 10 +- .../Mono.Linker.Tests/Extensions/NiceIO.cs | 10 +- .../Mono.Linker.Tests.csproj | 1 + .../TestCases/TestDatabase.cs | 3 +- .../TestCasesRunner/AssemblyChecker.cs | 24 +- .../TestCasesRunner/ILCompilerDriver.cs | 2 +- .../ILCompilerTestCaseResult.cs | 1 - .../TestCasesRunner/ILInputCompiler.cs | 2 +- .../TestCasesRunner/ResultChecker.cs | 15 +- .../TestCaseMetadataProvider.cs | 2 - ...estInfraMultiFileCompilationModuleGroup.cs | 13 +- .../TestCasesRunner/TestLogWriter.cs | 4 - .../TestCasesRunner/TestRunner.cs | 3 +- 695 files changed, 2890 insertions(+), 3395 deletions(-) diff --git a/src/coreclr/tools/Common/CommandLine/ArgumentParser.cs b/src/coreclr/tools/Common/CommandLine/ArgumentParser.cs index 86515f5cb132b..b538a669b93e7 100644 --- a/src/coreclr/tools/Common/CommandLine/ArgumentParser.cs +++ b/src/coreclr/tools/Common/CommandLine/ArgumentParser.cs @@ -18,7 +18,7 @@ public ArgumentParser(IEnumerable arguments) public ArgumentParser(IEnumerable arguments, Func> responseFileReader) { if (arguments == null) - throw new ArgumentNullException("arguments"); + throw new ArgumentNullException(nameof(arguments)); _tokens = ArgumentLexer.Lex(arguments, responseFileReader); } diff --git a/src/coreclr/tools/Common/CommandLine/ArgumentSyntax.cs b/src/coreclr/tools/Common/CommandLine/ArgumentSyntax.cs index 4cea1200b3a94..dea88074f329f 100644 --- a/src/coreclr/tools/Common/CommandLine/ArgumentSyntax.cs +++ b/src/coreclr/tools/Common/CommandLine/ArgumentSyntax.cs @@ -9,6 +9,7 @@ namespace Internal.CommandLine { public sealed partial class ArgumentSyntax { + private const string nameString = "name"; private readonly IEnumerable _arguments; private readonly List _commands = new List(); private readonly List _options = new List(); @@ -34,10 +35,10 @@ internal ArgumentSyntax(IEnumerable arguments) public static ArgumentSyntax Parse(IEnumerable arguments, Action defineAction) { if (arguments == null) - throw new ArgumentNullException("arguments"); + throw new ArgumentNullException(nameof(arguments)); if (defineAction == null) - throw new ArgumentNullException("defineAction"); + throw new ArgumentNullException(nameof(defineAction)); var syntax = new ArgumentSyntax(arguments); defineAction(syntax); @@ -107,12 +108,12 @@ public void ReportError(string message) public ArgumentCommand DefineCommand(string name, T value) { if (string.IsNullOrEmpty(name)) - throw new ArgumentException(Strings.NameMissing, "name"); + throw new ArgumentException(Strings.NameMissing, nameString); if (!IsValidName(name)) { var message = string.Format(Strings.CommandNameIsNotValidFmt, name); - throw new ArgumentException(message, "name"); + throw new ArgumentException(message, nameString); } if (_commands.Any(c => string.Equals(c.Name, name, StringComparison.Ordinal))) @@ -143,7 +144,7 @@ public ArgumentCommand DefineCommand(string name, T value) public Argument DefineOption(string name, T defaultValue, Func valueConverter, bool isRequired) { if (string.IsNullOrEmpty(name)) - throw new ArgumentException(Strings.NameMissing, "name"); + throw new ArgumentException(Strings.NameMissing, nameString); if (DefinedParameters.Any()) throw new InvalidOperationException(Strings.OptionsMustBeDefinedBeforeParameters); @@ -178,7 +179,7 @@ public Argument DefineOption(string name, T defaultValue, Func public ArgumentList DefineOptionList(string name, IReadOnlyList defaultValue, Func valueConverter, bool isRequired) { if (string.IsNullOrEmpty(name)) - throw new ArgumentException(Strings.NameMissing, "name"); + throw new ArgumentException(Strings.NameMissing, nameString); if (DefinedParameters.Any()) throw new InvalidOperationException(Strings.OptionsMustBeDefinedBeforeParameters); @@ -213,12 +214,12 @@ public ArgumentList DefineOptionList(string name, IReadOnlyList default public Argument DefineParameter(string name, T defaultValue, Func valueConverter) { if (string.IsNullOrEmpty(name)) - throw new ArgumentException(Strings.NameMissing, "name"); + throw new ArgumentException(Strings.NameMissing, nameString); if (!IsValidName(name)) { var message = string.Format(Strings.ParameterNameIsNotValidFmt, name); - throw new ArgumentException(message, "name"); + throw new ArgumentException(message, nameString); } if (DefinedParameters.Any(p => p.IsList)) @@ -252,12 +253,12 @@ public Argument DefineParameter(string name, T defaultValue, Func DefineParameterList(string name, IReadOnlyList defaultValue, Func valueConverter) { if (string.IsNullOrEmpty(name)) - throw new ArgumentException(Strings.NameMissing, "name"); + throw new ArgumentException(Strings.NameMissing, nameString); if (!IsValidName(name)) { var message = string.Format(Strings.ParameterNameIsNotValidFmt, name); - throw new ArgumentException(message, "name"); + throw new ArgumentException(message, nameString); } if (DefinedParameters.Any(p => p.IsList)) @@ -304,7 +305,7 @@ private IEnumerable ParseOptionNameList(string name) if (!IsValidName(alias)) { var message = string.Format(Strings.OptionNameIsNotValidFmt, alias); - throw new ArgumentException(message, "name"); + throw new ArgumentException(message, nameString); } foreach (var option in DefinedOptions) @@ -358,8 +359,7 @@ private ArgumentParser Parser { get { - if (_parser == null) - _parser = new ArgumentParser(_arguments, ParseResponseFile); + _parser ??= new ArgumentParser(_arguments, ParseResponseFile); return _parser; } @@ -457,15 +457,15 @@ public string GetHelpText(int maxWidth) public IReadOnlyList ExtraHelpParagraphs { + get + { + return _extraHelpParagraphs.ToArray(); + } set { _extraHelpParagraphs.Clear(); _extraHelpParagraphs.AddRange(value); } - get - { - return _extraHelpParagraphs.ToArray(); - } } } } diff --git a/src/coreclr/tools/Common/CommandLine/ArgumentSyntax_Definers.cs b/src/coreclr/tools/Common/CommandLine/ArgumentSyntax_Definers.cs index 0d98ced079d97..83d9f675b4218 100644 --- a/src/coreclr/tools/Common/CommandLine/ArgumentSyntax_Definers.cs +++ b/src/coreclr/tools/Common/CommandLine/ArgumentSyntax_Definers.cs @@ -10,7 +10,7 @@ namespace Internal.CommandLine public partial class ArgumentSyntax { private static readonly Func s_stringParser = v => v; - private static readonly Func s_booleanParser = v => bool.Parse(v); + private static readonly Func s_booleanParser = bool.Parse; private static readonly Func s_int32Parser = v => int.Parse(v, CultureInfo.InvariantCulture); // Commands diff --git a/src/coreclr/tools/Common/CommandLine/ArgumentToken.cs b/src/coreclr/tools/Common/CommandLine/ArgumentToken.cs index c93c63f961b52..83ef63435d84b 100644 --- a/src/coreclr/tools/Common/CommandLine/ArgumentToken.cs +++ b/src/coreclr/tools/Common/CommandLine/ArgumentToken.cs @@ -49,14 +49,14 @@ private bool Equals(ArgumentToken other) public override bool Equals(object obj) { - if (ReferenceEquals(obj, null)) + if (obj is null) return false; if (ReferenceEquals(obj, this)) return true; var other = obj as ArgumentToken; - return !ReferenceEquals(other, null) && Equals(other); + return other is not null && Equals(other); } public override int GetHashCode() diff --git a/src/coreclr/tools/Common/CommandLine/CommandLineException.cs b/src/coreclr/tools/Common/CommandLine/CommandLineException.cs index 1c42daf007f2a..3785047b6a5a5 100644 --- a/src/coreclr/tools/Common/CommandLine/CommandLineException.cs +++ b/src/coreclr/tools/Common/CommandLine/CommandLineException.cs @@ -5,7 +5,7 @@ namespace Internal.CommandLine { - internal class CommandLineException : Exception + internal sealed class CommandLineException : Exception { public CommandLineException(string message) : base(message) diff --git a/src/coreclr/tools/Common/CommandLine/CommandLineHelpers.cs b/src/coreclr/tools/Common/CommandLine/CommandLineHelpers.cs index 25f2c7b985191..d7fa472f748ac 100644 --- a/src/coreclr/tools/Common/CommandLine/CommandLineHelpers.cs +++ b/src/coreclr/tools/Common/CommandLine/CommandLineHelpers.cs @@ -12,7 +12,7 @@ namespace Internal.CommandLine // // Helpers for command line processing // - internal class Helpers + internal static class Helpers { // Helper to create a collection of paths unique in their simple names. public static void AppendExpandedPaths(Dictionary dictionary, string pattern, bool strict) @@ -102,7 +102,7 @@ public static void MakeReproPackage(string makeReproPath, string outputFilePath, } } - HashCode hashCodeOfArgs = new HashCode(); + HashCode hashCodeOfArgs = default(HashCode); foreach (string s in details) hashCodeOfArgs.Add(s); @@ -143,7 +143,7 @@ public static void MakeReproPackage(string makeReproPath, string outputFilePath, Dictionary dictionary = new Dictionary(); foreach (string optInList in (IEnumerable)option.Value) { - Helpers.AppendExpandedPaths(dictionary, optInList, false); + AppendExpandedPaths(dictionary, optInList, false); } foreach (string inputFile in dictionary.Values) { diff --git a/src/coreclr/tools/Common/CommandLine/HelpTextGenerator.cs b/src/coreclr/tools/Common/CommandLine/HelpTextGenerator.cs index afe1f0a1a5d11..3c2f621901321 100644 --- a/src/coreclr/tools/Common/CommandLine/HelpTextGenerator.cs +++ b/src/coreclr/tools/Common/CommandLine/HelpTextGenerator.cs @@ -65,7 +65,7 @@ private static void WriteUsage(this StringBuilder sb, string applicationName, IE sb.Append(usageHeader); if (syntaxElements.Any()) - sb.Append(@" "); + sb.Append(' '); var syntaxIndent = usageHeader.Length + 1; var syntaxMaxWidth = maxWidth - syntaxIndent; @@ -169,7 +169,7 @@ private static string GetOptionSyntax(Argument option) { var sb = new StringBuilder(); - sb.Append(@"["); + sb.Append('['); sb.Append(option.GetDisplayName()); if (!option.IsFlag) @@ -178,7 +178,7 @@ private static string GetOptionSyntax(Argument option) if (option.IsList) sb.Append(@"..."); - sb.Append(@"]"); + sb.Append(']'); return sb.ToString(); } @@ -252,7 +252,7 @@ private static IEnumerable WordWrapLines(IEnumerable tokens, int } if (sb.Length > 0) - sb.Append(@" "); + sb.Append(' '); sb.Append(token); } diff --git a/src/coreclr/tools/Common/Compiler/CodeGenerationFailedException.cs b/src/coreclr/tools/Common/Compiler/CodeGenerationFailedException.cs index 0001807c0cf48..671bb60ec2eb7 100644 --- a/src/coreclr/tools/Common/Compiler/CodeGenerationFailedException.cs +++ b/src/coreclr/tools/Common/Compiler/CodeGenerationFailedException.cs @@ -19,7 +19,7 @@ public CodeGenerationFailedException(MethodDesc method) } public CodeGenerationFailedException(MethodDesc method, Exception inner) - : base(String.Format(MessageText, method), inner) + : base(string.Format(MessageText, method), inner) { Method = method; } diff --git a/src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.Validation.cs b/src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.Validation.cs index 2766d7226bfb7..dcbccd62283ea 100644 --- a/src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.Validation.cs +++ b/src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.Validation.cs @@ -9,7 +9,7 @@ namespace ILCompiler { // Validates types to the extent that is required to make sure the compilation won't fail // in unpredictable spots. - partial class CompilerTypeSystemContext + public partial class CompilerTypeSystemContext { /// /// Ensures that the type can be fully loaded. The method will throw one of the type system @@ -33,7 +33,7 @@ public void EnsureLoadableMethod(MethodDesc method) } } - class ValidTypeHashTable : LockFreeReaderHashtable + private sealed class ValidTypeHashTable : LockFreeReaderHashtable { protected override bool CompareKeyToValue(TypeDesc key, TypeDesc value) => key == value; protected override bool CompareValueToValue(TypeDesc value1, TypeDesc value2) => value1 == value2; diff --git a/src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.cs b/src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.cs index 510a657cc84d7..21a1a0307e6c0 100644 --- a/src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.cs +++ b/src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.cs @@ -21,7 +21,7 @@ public partial class CompilerTypeSystemContext : MetadataTypeSystemContext, IMet private MetadataStringDecoder _metadataStringDecoder; - private class ModuleData + private sealed class ModuleData { public string SimpleName; public string FilePath; @@ -30,7 +30,7 @@ private class ModuleData public MemoryMappedViewAccessor MappedViewAccessor; } - private class ModuleHashtable : LockFreeReaderHashtable + private sealed class ModuleHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(EcmaModule key) { @@ -42,11 +42,11 @@ protected override int GetValueHashCode(ModuleData value) } protected override bool CompareKeyToValue(EcmaModule key, ModuleData value) { - return Object.ReferenceEquals(key, value.Module); + return ReferenceEquals(key, value.Module); } protected override bool CompareValueToValue(ModuleData value1, ModuleData value2) { - return Object.ReferenceEquals(value1.Module, value2.Module); + return ReferenceEquals(value1.Module, value2.Module); } protected override ModuleData CreateValueFromKey(EcmaModule key) { @@ -56,9 +56,9 @@ protected override ModuleData CreateValueFromKey(EcmaModule key) } private readonly ModuleHashtable _moduleHashtable = new ModuleHashtable(); - private class SimpleNameHashtable : LockFreeReaderHashtable + private sealed class SimpleNameHashtable : LockFreeReaderHashtable { - StringComparer _comparer = StringComparer.OrdinalIgnoreCase; + private StringComparer _comparer = StringComparer.OrdinalIgnoreCase; protected override int GetKeyHashCode(string key) { @@ -254,10 +254,8 @@ private EcmaModule AddModule(string filePath, string expectedSimpleName, bool us } finally { - if (mappedViewAccessor != null) - mappedViewAccessor.Dispose(); - if (pdbReader != null) - pdbReader.Dispose(); + mappedViewAccessor?.Dispose(); + pdbReader?.Dispose(); } } @@ -314,8 +312,7 @@ protected override TypeDesc ConvertToCanon(TypeDesc typeToConvert, ref Canonical public MetadataStringDecoder GetMetadataStringDecoder() { - if (_metadataStringDecoder == null) - _metadataStringDecoder = new CachingMetadataStringDecoder(0x10000); // TODO: Tune the size + _metadataStringDecoder ??= new CachingMetadataStringDecoder(0x10000); // TODO: Tune the size return _metadataStringDecoder; } @@ -354,11 +351,8 @@ private PdbSymbolReader OpenAssociatedSymbolFile(string peFilePath, PEReader peR // Try to open the symbol file as portable pdb first PdbSymbolReader reader = PortablePdbSymbolReader.TryOpen(pdbFileName, GetMetadataStringDecoder(), pdbContentId); - if (reader == null) - { - // Fallback to the diasymreader for non-portable pdbs - reader = UnmanagedPdbSymbolReader.TryOpenSymbolReaderForMetadataFile(peFilePath, Path.GetDirectoryName(pdbFileName)); - } + // Fallback to the diasymreader for non-portable pdbs + reader ??= UnmanagedPdbSymbolReader.TryOpenSymbolReaderForMetadataFile(peFilePath, Path.GetDirectoryName(pdbFileName)); return reader; } diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/CompilerComparer.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/CompilerComparer.cs index 46f9e704a848b..c95c6c318dc0c 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/CompilerComparer.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/CompilerComparer.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Diagnostics; using System.Collections.Generic; diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/EmbeddedDataContainerNode.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/EmbeddedDataContainerNode.cs index da756fcd16b55..3aa40631fb3fa 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/EmbeddedDataContainerNode.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/EmbeddedDataContainerNode.cs @@ -1,12 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Internal.TypeSystem; - namespace ILCompiler.DependencyAnalysis { /// - /// Represents a node that contains a set of embedded objects. The main function is + /// Represents a node that contains a set of embedded objects. The main function is /// to serve as a base class, providing symbol name boundaries and node ordering. /// public abstract class EmbeddedDataContainerNode : ObjectNode diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/INodeWithRuntimeDeterminedDependencies.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/INodeWithRuntimeDeterminedDependencies.cs index 301cf4d2948b1..645835a365d4c 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/INodeWithRuntimeDeterminedDependencies.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/INodeWithRuntimeDeterminedDependencies.cs @@ -4,11 +4,10 @@ using System.Collections.Generic; using Internal.TypeSystem; +using DependencyListEntry = ILCompiler.DependencyAnalysisFramework.DependencyNodeCore.DependencyListEntry; namespace ILCompiler.DependencyAnalysis { - using DependencyListEntry = DependencyAnalysisFramework.DependencyNodeCore.DependencyListEntry; - /// /// Represents a node whose dependencies are runtime determined (they depend on the generic context) /// and which provides means to compute concrete dependencies when given the generic context. diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ISymbolNode.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ISymbolNode.cs index 92ea4ca92b159..336c012150295 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ISymbolNode.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ISymbolNode.cs @@ -76,13 +76,12 @@ public interface ISymbolDefinitionNode : ISymbolNode public static class ISymbolNodeExtensions { [ThreadStatic] - static Utf8StringBuilder s_cachedUtf8StringBuilder; + private static Utf8StringBuilder s_cachedUtf8StringBuilder; public static string GetMangledName(this ISymbolNode symbolNode, NameMangler nameMangler) { Utf8StringBuilder sb = s_cachedUtf8StringBuilder; - if (sb == null) - sb = new Utf8StringBuilder(); + sb ??= new Utf8StringBuilder(); symbolNode.AppendMangledName(nameMangler, sb); string ret = sb.ToString(); diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/MethodReadOnlyDataNode.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/MethodReadOnlyDataNode.cs index 205266622422e..9a8e941f0225d 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/MethodReadOnlyDataNode.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/MethodReadOnlyDataNode.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Diagnostics; using Internal.Text; @@ -52,4 +51,3 @@ public override int CompareToImpl(ISortableNode other, CompilerComparer comparer #endif } } - diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectAndOffsetSymbolNode.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectAndOffsetSymbolNode.cs index ab8cb36d111b8..0f15706ea685c 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectAndOffsetSymbolNode.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectAndOffsetSymbolNode.cs @@ -24,7 +24,7 @@ public ObjectAndOffsetSymbolNode(ObjectNode obj, int offset, Utf8String name, bo _includeCompilationUnitPrefix = includeCompilationUnitPrefix; } - protected override string GetName(NodeFactory factory) => $"Symbol {_name.ToString()} at offset {_offset.ToStringInvariant()}"; + protected override string GetName(NodeFactory factory) => $"Symbol {_name} at offset {_offset.ToStringInvariant()}"; public override bool HasConditionalStaticDependencies => false; public override bool HasDynamicDependencies => false; diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectDataBuilder.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectDataBuilder.cs index f20020ad71051..6645f556d0f0e 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectDataBuilder.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectDataBuilder.cs @@ -21,10 +21,10 @@ public ObjectDataBuilder(NodeFactory factory, bool relocsOnly) : this(factory.Ta public ObjectDataBuilder(TargetDetails target, bool relocsOnly) { _target = target; - _data = new ArrayBuilder(); - _relocs = new ArrayBuilder(); + _data = default(ArrayBuilder); + _relocs = default(ArrayBuilder); Alignment = 1; - _definedSymbols = new ArrayBuilder(); + _definedSymbols = default(ArrayBuilder); #if DEBUG _numReservations = 0; _checkAllSymbolDependenciesMustBeMarked = !relocsOnly; @@ -308,7 +308,7 @@ public void EmitReloc(ISymbolNode symbol, RelocType relocType, int delta = 0) Debug.Assert(delta == 0); // Do not vacate space for this kind of relocation, because // the space is embedded in the instruction. - break; + break; default: throw new NotImplementedException(); } diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectNode.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectNode.cs index 68b984519d278..5122c584ae041 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectNode.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectNode.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using ILCompiler.DependencyAnalysisFramework; -using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis { @@ -61,8 +60,7 @@ public sealed override IEnumerable GetStaticDependencies(No if (relocs != null) { - if (dependencies == null) - dependencies = new DependencyList(); + dependencies ??= new DependencyList(); foreach (Relocation reloc in relocs) { diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectNodeSection.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectNodeSection.cs index f4a6179b7f393..c5ad884fa4c93 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectNodeSection.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectNodeSection.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace ILCompiler.DependencyAnalysis { public enum SectionType @@ -41,7 +39,7 @@ public bool IsStandardSection return this == DataSection || this == ReadOnlyDataSection || this == FoldableReadOnlyDataSection || this == TextSection || this == XDataSection || this == BssSection; } } - + public static readonly ObjectNodeSection XDataSection = new ObjectNodeSection("xdata", SectionType.ReadOnly); public static readonly ObjectNodeSection DataSection = new ObjectNodeSection("data", SectionType.Writeable); public static readonly ObjectNodeSection ReadOnlyDataSection = new ObjectNodeSection("rdata", SectionType.ReadOnly); diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ShadowConcreteMethodNode.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ShadowConcreteMethodNode.cs index 57ea2b981490d..140a97f70924e 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ShadowConcreteMethodNode.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ShadowConcreteMethodNode.cs @@ -85,7 +85,7 @@ public override IEnumerable GetStaticDependencies(NodeFacto return dependencies; } - protected override string GetName(NodeFactory factory) => $"{Method.ToString()} backed by {CanonicalMethodNode.GetMangledName(factory.NameMangler)}"; + protected override string GetName(NodeFactory factory) => $"{Method} backed by {CanonicalMethodNode.GetMangledName(factory.NameMangler)}"; public sealed override bool HasConditionalStaticDependencies => false; public sealed override bool HasDynamicDependencies => false; diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/SortableDependencyNode.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/SortableDependencyNode.cs index 2c677d51b052c..a29c732e0814e 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/SortableDependencyNode.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/SortableDependencyNode.cs @@ -7,7 +7,6 @@ using System.Runtime.CompilerServices; using ILCompiler.DependencyAnalysisFramework; -using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis { @@ -49,7 +48,7 @@ protected enum ObjectNodePhase protected enum ObjectNodeOrder { // - // The ordering of this sequence of nodes is deliberate and currently required for + // The ordering of this sequence of nodes is deliberate and currently required for // compiler correctness. // diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM/ARMEmitter.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM/ARMEmitter.cs index 53bcb335e0542..dd41f891552a1 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM/ARMEmitter.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM/ARMEmitter.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Diagnostics; namespace ILCompiler.DependencyAnalysis.ARM @@ -82,7 +81,7 @@ public void EmitDebugBreak() Builder.EmitByte(0xde); Builder.EmitByte(0xfe); } - + // push reg // reg range: [0..12, LR] public void EmitPUSH(Register reg) diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM/Register.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM/Register.cs index 59cc4b74753f1..5217786257072 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM/Register.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM/Register.cs @@ -1,12 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace ILCompiler.DependencyAnalysis.ARM { public enum Register @@ -27,7 +21,7 @@ public enum Register R13 = 13, R14 = 14, R15 = 15, - + None = 16, RegDirect = 24, diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM/TargetRegisterMap.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM/TargetRegisterMap.cs index 73dc986c56973..4091fa2634407 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM/TargetRegisterMap.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM/TargetRegisterMap.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis.ARM diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM64/ARM64Emitter.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM64/ARM64Emitter.cs index 895f2f9d1a055..7ef040f23c285 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM64/ARM64Emitter.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM64/ARM64Emitter.cs @@ -175,11 +175,11 @@ public void EmitJE(ISymbolNode symbol) uint offset = symbol.RepresentsIndirectionCell ? 6u : 2u; Builder.EmitUInt(0b01010100_0000000000000000000_0_0001u | offset << 5); - + EmitJMP(symbol); } - private bool InSignedByteRange(int i) + private static bool InSignedByteRange(int i) { return i == (int)(sbyte)i; } diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM64/AddrMode.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM64/AddrMode.cs index 410eb8b349fa9..e984d130bc22d 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM64/AddrMode.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM64/AddrMode.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace ILCompiler.DependencyAnalysis.ARM64 { public enum AddrModeSize diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM64/Register.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM64/Register.cs index aa102c85db7a0..05b853de18c3a 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM64/Register.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM64/Register.cs @@ -1,12 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace ILCompiler.DependencyAnalysis.ARM64 { public enum Register @@ -42,9 +36,9 @@ public enum Register X28 = 28, X29 = 29, X30 = 30, - + X31 = 31, - + None = 32, NoIndex = 128, } diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM64/TargetRegisterMap.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM64/TargetRegisterMap.cs index 5a328f4c650a2..1ea6409b34d19 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM64/TargetRegisterMap.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM64/TargetRegisterMap.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis.ARM64 diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_LoongArch64/AddrMode.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_LoongArch64/AddrMode.cs index 5616941cae238..117c766383d93 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_LoongArch64/AddrMode.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_LoongArch64/AddrMode.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace ILCompiler.DependencyAnalysis.LoongArch64 { public enum AddrModeSize diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_LoongArch64/Register.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_LoongArch64/Register.cs index 1ce65e7662287..445964479742b 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_LoongArch64/Register.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_LoongArch64/Register.cs @@ -1,12 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace ILCompiler.DependencyAnalysis.LoongArch64 { public enum Register diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_LoongArch64/TargetRegisterMap.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_LoongArch64/TargetRegisterMap.cs index a1b5808c94b44..e66dd4824e351 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_LoongArch64/TargetRegisterMap.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_LoongArch64/TargetRegisterMap.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis.LoongArch64 diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X64/AddrMode.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X64/AddrMode.cs index c787523125fea..f13f68773f344 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X64/AddrMode.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X64/AddrMode.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace ILCompiler.DependencyAnalysis.X64 { public enum AddrModeSize diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X64/Register.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X64/Register.cs index 9b88bd6159527..09768266eb065 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X64/Register.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X64/Register.cs @@ -1,12 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace ILCompiler.DependencyAnalysis.X64 { public enum Register diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X64/X64Emitter.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X64/X64Emitter.cs index 17135f6c4e405..b88bb7f1002c5 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X64/X64Emitter.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X64/X64Emitter.cs @@ -189,7 +189,7 @@ public void EmitZeroReg(Register reg) Builder.EmitByte((byte)(0xC0 | (((int)reg & 0x07) << 3) | ((int)reg & 0x07))); } - private bool InSignedByteRange(int i) + private static bool InSignedByteRange(int i) { return i == (int)(sbyte)i; } @@ -228,8 +228,7 @@ private void EmitModRM(byte subOpcode, ref AddrMode addrMode) { byte lowOrderBitsOfBaseReg = (byte)((int)addrMode.BaseReg & 0x07); modRM |= lowOrderBitsOfBaseReg; - int offsetSize = 0; - + int offsetSize; if (addrMode.Offset == 0 && (lowOrderBitsOfBaseReg != (byte)Register.RBP)) { offsetSize = 0; @@ -250,7 +249,7 @@ private void EmitModRM(byte subOpcode, ref AddrMode addrMode) if (addrMode.BaseReg == Register.None) { - //# ifdef _TARGET_AMD64_ + //# ifdef _TARGET_AMD64_ // x64 requires SIB to avoid RIP relative address emitSibByte = true; //#else @@ -287,7 +286,7 @@ private void EmitModRM(byte subOpcode, ref AddrMode addrMode) modRM = (byte)((modRM & 0xF8) | (int)Register.RSP); Builder.EmitByte(modRM); - int indexRegAsInt = (int)(addrMode.IndexReg.HasValue ? addrMode.IndexReg.Value : Register.RSP); + int indexRegAsInt = (int)(addrMode.IndexReg ?? Register.RSP); Builder.EmitByte((byte)((addrMode.Scale << 6) + ((indexRegAsInt & 0x07) << 3) + ((int)sibByteBaseRegister & 0x07))); } diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X86/AddrMode.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X86/AddrMode.cs index b09e5a32ad152..302e234ded374 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X86/AddrMode.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X86/AddrMode.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace ILCompiler.DependencyAnalysis.X86 { public enum AddrModeSize diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X86/Register.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X86/Register.cs index e75f86e6bc375..4989557832c2e 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X86/Register.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X86/Register.cs @@ -1,12 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace ILCompiler.DependencyAnalysis.X86 { public enum Register @@ -19,7 +13,7 @@ public enum Register EBP = 5, ESI = 6, EDI = 7, - + None = 8, RegDirect = 24, diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X86/TargetRegisterMap.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X86/TargetRegisterMap.cs index 70ca0daf934d1..de2c913f8e1a5 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X86/TargetRegisterMap.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X86/TargetRegisterMap.cs @@ -26,7 +26,7 @@ public TargetRegisterMap(TargetOS os) Arg1 = Register.EDX; Result = Register.EAX; break; - + default: throw new NotImplementedException(); } diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X86/X86Emitter.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X86/X86Emitter.cs index cd95c3cbcf0b5..e386e9a34da6d 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X86/X86Emitter.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X86/X86Emitter.cs @@ -118,7 +118,7 @@ public void EmitRETIfEqual() Builder.EmitByte(0xC3); } - private bool InSignedByteRange(int i) + private static bool InSignedByteRange(int i) { return i == (int)(sbyte)i; } @@ -157,8 +157,7 @@ private void EmitModRM(byte subOpcode, ref AddrMode addrMode) { byte lowOrderBitsOfBaseReg = (byte)((int)addrMode.BaseReg & 0x07); modRM |= lowOrderBitsOfBaseReg; - int offsetSize = 0; - + int offsetSize; if (addrMode.Offset == 0 && (lowOrderBitsOfBaseReg != (byte)Register.EBP)) { offsetSize = 0; @@ -208,7 +207,7 @@ private void EmitModRM(byte subOpcode, ref AddrMode addrMode) { modRM = (byte)((modRM & 0xF8) | (int)Register.ESP); Builder.EmitByte(modRM); - int indexRegAsInt = (int)(addrMode.IndexReg.HasValue ? addrMode.IndexReg.Value : Register.ESP); + int indexRegAsInt = (int)(addrMode.IndexReg ?? Register.ESP); Builder.EmitByte((byte)((addrMode.Scale << 6) + ((indexRegAsInt & 0x07) << 3) + ((int)sibByteBaseRegister & 0x07))); } EmitImmediate(addrMode.Offset, offsetSize); @@ -226,7 +225,7 @@ private void EmitExtendedOpcode(int opcode) Builder.EmitByte((byte)(opcode >> 16)); } Builder.EmitByte((byte)(opcode >> 8)); - } + } private void EmitIndirInstruction(int opcode, byte subOpcode, ref AddrMode addrMode) { diff --git a/src/coreclr/tools/Common/Compiler/DevirtualizationManager.cs b/src/coreclr/tools/Common/Compiler/DevirtualizationManager.cs index 2fb34cede261f..6222ec6d649cc 100644 --- a/src/coreclr/tools/Common/Compiler/DevirtualizationManager.cs +++ b/src/coreclr/tools/Common/Compiler/DevirtualizationManager.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using Internal.TypeSystem; using CORINFO_DEVIRTUALIZATION_DETAIL = Internal.JitInterface.CORINFO_DEVIRTUALIZATION_DETAIL; using Debug = System.Diagnostics.Debug; @@ -107,7 +106,6 @@ protected virtual MethodDesc ResolveVirtualMethod(MethodDesc declMethod, DefType } else { - MethodDesc dimMethod = null; // This isn't the correct lookup algorithm for variant default interface methods // but as we will drop any results we find in any case, it doesn't matter much. // Non-variant dispatch can simply use ResolveInterfaceMethodToDefaultImplementationOnType @@ -130,6 +128,7 @@ protected virtual MethodDesc ResolveVirtualMethod(MethodDesc declMethod, DefType if (defaultInterfaceDispatchDeclMethod != null) { + MethodDesc dimMethod; switch (implType.ResolveInterfaceMethodToDefaultImplementationOnType(defaultInterfaceDispatchDeclMethod, out dimMethod)) { case DefaultInterfaceMethodResolution.Diamond: diff --git a/src/coreclr/tools/Common/Compiler/DisplayNameHelpers.cs b/src/coreclr/tools/Common/Compiler/DisplayNameHelpers.cs index 4ff382a8bf6e1..f296188fcc17b 100644 --- a/src/coreclr/tools/Common/Compiler/DisplayNameHelpers.cs +++ b/src/coreclr/tools/Common/Compiler/DisplayNameHelpers.cs @@ -7,8 +7,6 @@ using Internal.TypeSystem; using Internal.TypeSystem.Ecma; -using Debug = System.Diagnostics.Debug; - namespace ILCompiler { public static class DisplayNameHelpers @@ -123,9 +121,9 @@ public static string GetDisplayNameWithoutNamespace(this TypeDesc type) return Formatter.Instance.FormatName(type, FormatOptions.None); } - private class Formatter : TypeNameFormatter + private sealed class Formatter : TypeNameFormatter { - public readonly static Formatter Instance = new Formatter(); + public static readonly Formatter Instance = new Formatter(); public override Unit AppendName(StringBuilder sb, ArrayType type, FormatOptions options) { @@ -226,7 +224,7 @@ protected override Unit AppendNameForNestedType(StringBuilder sb, DefType nested return default; } - private void NamespaceQualify(StringBuilder sb, DefType type, FormatOptions options) + private static void NamespaceQualify(StringBuilder sb, DefType type, FormatOptions options) { if ((options & FormatOptions.NamespaceQualify) != 0) { diff --git a/src/coreclr/tools/Common/Compiler/HardwareIntrinsicHelpers.cs b/src/coreclr/tools/Common/Compiler/HardwareIntrinsicHelpers.cs index f20fa1ae352b4..a523f1c5f0979 100644 --- a/src/coreclr/tools/Common/Compiler/HardwareIntrinsicHelpers.cs +++ b/src/coreclr/tools/Common/Compiler/HardwareIntrinsicHelpers.cs @@ -1,12 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.TypeSystem; -using Internal.IL; -using Internal.IL.Stubs; -using System.Diagnostics; namespace ILCompiler { diff --git a/src/coreclr/tools/Common/Compiler/InstructionSetSupport.cs b/src/coreclr/tools/Common/Compiler/InstructionSetSupport.cs index 1ce1851dc1d10..affc29d19310c 100644 --- a/src/coreclr/tools/Common/Compiler/InstructionSetSupport.cs +++ b/src/coreclr/tools/Common/Compiler/InstructionSetSupport.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using Internal.TypeSystem; using Internal.JitInterface; @@ -124,8 +123,8 @@ public SimdVectorLength GetVectorTSimdVector() public class InstructionSetSupportBuilder { - static Dictionary> s_instructionSetSupport = ComputeInstructionSetSupport(); - static Dictionary s_nonSpecifiableInstructionSets = ComputeNonSpecifiableInstructionSetSupport(); + private static Dictionary> s_instructionSetSupport = ComputeInstructionSetSupport(); + private static Dictionary s_nonSpecifiableInstructionSets = ComputeNonSpecifiableInstructionSetSupport(); private static Dictionary> ComputeInstructionSetSupport() { diff --git a/src/coreclr/tools/Common/Compiler/MethodExtensions.cs b/src/coreclr/tools/Common/Compiler/MethodExtensions.cs index 7e22fe2c4a7b8..dc7831c6f8a51 100644 --- a/src/coreclr/tools/Common/Compiler/MethodExtensions.cs +++ b/src/coreclr/tools/Common/Compiler/MethodExtensions.cs @@ -1,12 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using Internal.TypeSystem; using Internal.TypeSystem.Ecma; -using Debug = System.Diagnostics.Debug; - namespace ILCompiler { public static class MethodExtensions diff --git a/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs b/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs index 65e58642acaf4..1c7c24694d27f 100644 --- a/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs +++ b/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs @@ -32,12 +32,12 @@ public NativeAotNameMangler(NodeMangler nodeMangler, bool mangleForCplusPlus) : public override string CompilationUnitPrefix { - set { _compilationUnitPrefix = SanitizeNameWithHash(value); } get { Debug.Assert(_compilationUnitPrefix != null); return _compilationUnitPrefix; } + set { _compilationUnitPrefix = SanitizeNameWithHash(value); } } // @@ -52,8 +52,7 @@ public override string SanitizeName(string s, bool typeName = false) if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) { - if (sb != null) - sb.Append(c); + sb?.Append(c); continue; } @@ -62,17 +61,14 @@ public override string SanitizeName(string s, bool typeName = false) // C identifiers cannot start with a digit. Prepend underscores. if (i == 0) { - if (sb == null) - sb = new StringBuilder(s.Length + 2); - sb.Append("_"); + sb ??= new StringBuilder(s.Length + 2); + sb.Append('_'); } - if (sb != null) - sb.Append(c); + sb?.Append(c); continue; } - if (sb == null) - sb = new StringBuilder(s, 0, i, s.Length); + sb ??= new StringBuilder(s, 0, i, s.Length); // For CppCodeGen, replace "." (C# namespace separator) with "::" (C++ namespace separator) if (typeName && c == '.' && _mangleForCplusPlus) @@ -83,7 +79,7 @@ public override string SanitizeName(string s, bool typeName = false) // Everything else is replaced by underscore. // TODO: We assume that there won't be collisions with our own or C++ built-in identifiers. - sb.Append("_"); + sb.Append('_'); } string sanitizedName = (sb != null) ? sb.ToString() : s; @@ -121,14 +117,11 @@ private string SanitizeNameWithHash(string literal) byte[] hash; lock (this) { - if (_sha256 == null) - { - // Use SHA256 hash here to provide a high degree of uniqueness to symbol names without requiring them to be long - // This hash function provides an exceedingly high likelihood that no two strings will be given equal symbol names - // This is not considered used for security purpose; however collisions would be highly unfortunate as they will cause compilation - // failure. - _sha256 = SHA256.Create(); - } + // Use SHA256 hash here to provide a high degree of uniqueness to symbol names without requiring them to be long + // This hash function provides an exceedingly high likelihood that no two strings will be given equal symbol names + // This is not considered used for security purpose; however collisions would be highly unfortunate as they will cause compilation + // failure. + _sha256 ??= SHA256.Create(); hash = _sha256.ComputeHash(GetBytesFromString(literal)); } @@ -151,7 +144,7 @@ private string SanitizeNameWithHash(string literal) /// Name to check for uniqueness. /// Set of names already used. /// A name based on that is not part of . - private string DisambiguateName(string origName, ISet set) + private static string DisambiguateName(string origName, ISet set) { int iter = 0; string result = origName; @@ -193,10 +186,8 @@ protected string NestMangledName(string name) /// Mangled name for . private string ComputeMangledTypeName(TypeDesc type) { - if (type is EcmaType) + if (type is EcmaType ecmaType) { - EcmaType ecmaType = (EcmaType)type; - string assemblyName = ((EcmaAssembly)ecmaType.EcmaModule).GetName().Name; bool isSystemPrivate = assemblyName.StartsWith("System.Private."); @@ -204,7 +195,7 @@ private string ComputeMangledTypeName(TypeDesc type) // but we already have a problem due to running SanitizeName without disambiguating the result // This problem needs a better fix. if (isSystemPrivate && !_mangleForCplusPlus) - assemblyName = "S.P." + assemblyName.Substring(15); + assemblyName = string.Concat("S.P.", assemblyName.AsSpan(15)); string prependAssemblyName = SanitizeName(assemblyName); var deduplicator = new HashSet(); diff --git a/src/coreclr/tools/Common/Compiler/TypeExtensions.cs b/src/coreclr/tools/Common/Compiler/TypeExtensions.cs index 47cdc09d7bb93..f50028f09c4af 100644 --- a/src/coreclr/tools/Common/Compiler/TypeExtensions.cs +++ b/src/coreclr/tools/Common/Compiler/TypeExtensions.cs @@ -3,8 +3,6 @@ using System; using System.Runtime.CompilerServices; - -using Internal.IL; using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; @@ -91,9 +89,9 @@ public static bool IsArrayAddressMethod(this MethodDesc method) public static bool IsArrayMethod(this MethodDesc method) { var arrayMethod = method as ArrayMethod; - return arrayMethod != null && (arrayMethod.Kind == ArrayMethodKind.Address || - arrayMethod.Kind == ArrayMethodKind.Get || - arrayMethod.Kind == ArrayMethodKind.Set || + return arrayMethod != null && (arrayMethod.Kind == ArrayMethodKind.Address || + arrayMethod.Kind == ArrayMethodKind.Get || + arrayMethod.Kind == ArrayMethodKind.Set || arrayMethod.Kind == ArrayMethodKind.Ctor); } @@ -279,7 +277,7 @@ public static TypeDesc MergeTypesToCommonParent(TypeDesc ta, TypeDesc tb) if (ta.IsInterface) { // - // Both classes are interfaces. Check that if one + // Both classes are interfaces. Check that if one // interface extends the other. // // Does tb extend ta ? diff --git a/src/coreclr/tools/Common/Compiler/VectorFieldLayoutAlgorithm.cs b/src/coreclr/tools/Common/Compiler/VectorFieldLayoutAlgorithm.cs index a4e49bde5fec5..e2be877405872 100644 --- a/src/coreclr/tools/Common/Compiler/VectorFieldLayoutAlgorithm.cs +++ b/src/coreclr/tools/Common/Compiler/VectorFieldLayoutAlgorithm.cs @@ -36,7 +36,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp { if (defType.Context.Target.Architecture == TargetArchitecture.ARM) { - // The Procedure Call Standard for ARM defaults to 8-byte alignment for __m128 + // The Procedure Call Standard for ARM defaults to 8-byte alignment for __m128 alignment = new LayoutInt(8); } else @@ -50,13 +50,13 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp if (defType.Context.Target.Architecture == TargetArchitecture.ARM) { - // No such type exists for the Procedure Call Standard for ARM. We will default + // No such type exists for the Procedure Call Standard for ARM. We will default // to the same alignment as __m128, which is supported by the ABI. alignment = new LayoutInt(8); } else if (defType.Context.Target.Architecture == TargetArchitecture.ARM64) { - // The Procedure Call Standard for ARM 64-bit (with SVE support) defaults to + // The Procedure Call Standard for ARM 64-bit (with SVE support) defaults to // 16-byte alignment for __m256. alignment = new LayoutInt(16); } diff --git a/src/coreclr/tools/Common/Internal/LowLevelLinq/LowLevelEnumerable.ToList.cs b/src/coreclr/tools/Common/Internal/LowLevelLinq/LowLevelEnumerable.ToList.cs index 8ab46e8b8caea..09fa4608ff6d5 100644 --- a/src/coreclr/tools/Common/Internal/LowLevelLinq/LowLevelEnumerable.ToList.cs +++ b/src/coreclr/tools/Common/Internal/LowLevelLinq/LowLevelEnumerable.ToList.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Diagnostics; using System.Collections.Generic; namespace Internal.LowLevelLinq diff --git a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MdBinaryReader.cs b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MdBinaryReader.cs index 660c2f5d20d36..b52493d1b4bb1 100644 --- a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MdBinaryReader.cs +++ b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MdBinaryReader.cs @@ -1,13 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.IO; -using System.Collections.Generic; -using System.Reflection; -using Debug = System.Diagnostics.Debug; -using System.Threading; -using System.Text; using Internal.NativeFormat; namespace Internal.Metadata.NativeFormat diff --git a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MdBinaryReaderGen.cs b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MdBinaryReaderGen.cs index d0e425b36790b..f295f220a0d99 100644 --- a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MdBinaryReaderGen.cs +++ b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MdBinaryReaderGen.cs @@ -5,12 +5,8 @@ #pragma warning disable 649 -using System; -using System.IO; -using System.Collections.Generic; using System.Reflection; using Internal.NativeFormat; -using Debug = System.Diagnostics.Debug; namespace Internal.Metadata.NativeFormat { diff --git a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeFormatReaderGen.cs b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeFormatReaderGen.cs index faa24815ba5c9..ad38fab1bf24e 100644 --- a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeFormatReaderGen.cs +++ b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeFormatReaderGen.cs @@ -10700,7 +10700,7 @@ public ConstantStringArray GetConstantStringArray(ConstantStringArrayHandle hand public ConstantStringValue GetConstantStringValue(ConstantStringValueHandle handle) { if (IsNull(handle)) - return new ConstantStringValue(); + return default(ConstantStringValue); ConstantStringValue record; record._reader = this; record._handle = handle; diff --git a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeMetadataReader.cs b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeMetadataReader.cs index 170dbc9efda39..673867d0f9946 100644 --- a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeMetadataReader.cs +++ b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeMetadataReader.cs @@ -6,10 +6,12 @@ #pragma warning disable CA1066 // IEquatable implementations aren't used using System; +#pragma warning disable IDE0005 // Using directive is unnecessary. using System.IO; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; +#pragma warning restore IDE0005 // Using directive is unnecessary. using Internal.NativeFormat; namespace Internal.Metadata.NativeFormat @@ -248,7 +250,7 @@ internal bool StringEquals(ConstantStringValueHandle handle, string value) } } - internal partial class MetadataHeader + internal sealed partial class MetadataHeader { /// /// Signature should be updated every time the metadata schema changes. diff --git a/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatReader.Primitives.cs b/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatReader.Primitives.cs index e30810799e605..7f7a8ebdcec53 100644 --- a/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatReader.Primitives.cs +++ b/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatReader.Primitives.cs @@ -7,9 +7,7 @@ // Utilities to read native data from images, that are written by the NativeFormatWriter engine // --------------------------------------------------------------------------- -using System; using System.Diagnostics; -using System.Runtime.CompilerServices; namespace Internal.NativeFormat { diff --git a/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatReader.String.cs b/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatReader.String.cs index a044494d83432..e3b90b71132bf 100644 --- a/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatReader.String.cs +++ b/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatReader.String.cs @@ -7,7 +7,6 @@ // UTF8 string reading methods // --------------------------------------------------------------------------- -using System; using System.Text; namespace Internal.NativeFormat diff --git a/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatReader.cs b/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatReader.cs index 61dcffe240304..91ed075a79dd2 100644 --- a/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatReader.cs +++ b/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatReader.cs @@ -9,7 +9,6 @@ using System; using System.Diagnostics; -using System.Runtime.CompilerServices; namespace Internal.NativeFormat { @@ -215,7 +214,7 @@ public static void SkipInteger(ref byte* stream) } } - internal unsafe partial class NativeReader + internal sealed unsafe partial class NativeReader { private readonly byte* _base; private readonly uint _size; diff --git a/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatWriter.cs b/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatWriter.cs index e81869f783a38..70b45a8d15ab3 100644 --- a/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatWriter.cs +++ b/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatWriter.cs @@ -92,24 +92,23 @@ public Vertex Pop() #endif class NativeWriter { - List
_sections = new List
(); + private List
_sections = new List
(); - enum SavePhase + private enum SavePhase { Initial, Shrinking, Growing } + private int _iteration; + private SavePhase _phase; // Current save phase + private int _offsetAdjustment; // Cumulative offset adjustment compared to previous iteration + private int _paddingSize; // How much padding was used - int _iteration = 0; - SavePhase _phase; // Current save phase - int _offsetAdjustment; // Cumulative offset adjustment compared to previous iteration - int _paddingSize; // How much padding was used + private Dictionary _unifier = new Dictionary(); - Dictionary _unifier = new Dictionary(); - - NativePrimitiveEncoder _encoder = new NativePrimitiveEncoder(); + private NativePrimitiveEncoder _encoder; #if NATIVEFORMAT_COMPRESSION struct Tentative @@ -403,11 +402,11 @@ public void Save(Stream stream) internal struct TypeSignatureCompressor { internal TypeSignatureCompressor(NativeWriter pWriter) { } - internal void Pack(Vertex vertex) { } + internal static void Pack(Vertex vertex) { } } #endif - T Unify(T vertex) where T : Vertex + private T Unify(T vertex) where T : Vertex { Vertex existing; if (_unifier.TryGetValue(vertex, out existing)) @@ -537,9 +536,9 @@ public Vertex GetCallingConventionConverterSignature(uint flags, Vertex signatur } } - class PlacedVertex : Vertex + internal sealed class PlacedVertex : Vertex { - Vertex _unified; + private Vertex _unified; public PlacedVertex(Vertex unified) { @@ -559,7 +558,7 @@ internal override void Save(NativeWriter writer) #endif class UnsignedConstant : Vertex { - uint _value; + private uint _value; public UnsignedConstant(uint value) { @@ -586,7 +585,7 @@ public override bool Equals(object other) } } - class Tuple : Vertex + internal sealed class Tuple : Vertex { private Vertex _item1; private Vertex _item2; @@ -603,8 +602,7 @@ internal override void Save(NativeWriter writer) { _item1.Save(writer); _item2.Save(writer); - if (_item3 != null) - _item3.Save(writer); + _item3?.Save(writer); } public override int GetHashCode() @@ -621,9 +619,9 @@ public override bool Equals(object obj) if (other == null) return false; - return Object.Equals(_item1, other._item1) && - Object.Equals(_item2, other._item2) && - Object.Equals(_item3, other._item3); + return Equals(_item1, other._item1) && + Equals(_item2, other._item2) && + Equals(_item3, other._item3); } } @@ -639,9 +637,9 @@ public override bool Equals(object obj) #endif class VertexBag : Vertex { - enum EntryType { Vertex, Unsigned, Signed } + private enum EntryType { Vertex, Unsigned, Signed } - struct Entry + private struct Entry { internal BagElementKind _id; internal EntryType _type; @@ -752,7 +750,7 @@ public override bool Equals(object obj) return false; for (int i = 0; i < _elements.Count; i++) - if (!Object.Equals(_elements[i], other._elements[i])) + if (!Equals(_elements[i], other._elements[i])) return false; return true; @@ -804,7 +802,7 @@ public override bool Equals(object obj) if (other == null) return false; - return Object.Equals(_methodName, other._methodName) && Object.Equals(_signature, other._signature); + return Equals(_methodName, other._methodName) && Equals(_signature, other._signature); } } @@ -876,7 +874,7 @@ public override bool Equals(object obj) if (other == null) return false; - return Object.Equals(_item, other._item); + return Equals(_item, other._item); } } @@ -916,7 +914,7 @@ public override bool Equals(object obj) if (other == null) return false; - return Object.Equals(_item, other._item); + return Equals(_item, other._item); } } @@ -936,11 +934,9 @@ public ExternalTypeSignature(uint externalTypeId) internal override void Save(NativeWriter writer) { - NativeWriter.TypeSignatureCompressor compressor = new NativeWriter.TypeSignatureCompressor(writer); - writer.WriteUnsigned((uint)TypeSignatureKind.External | (_externalTypeId << 4)); - compressor.Pack(this); + NativeWriter.TypeSignatureCompressor.Pack(this); } public override int GetHashCode() @@ -1021,8 +1017,8 @@ public override bool Equals(object obj) if (!( _flags == other._flags && _fptrReferenceId == other._fptrReferenceId && - Object.Equals(_containingType, other._containingType) && - Object.Equals(_methodNameAndSig, other._methodNameAndSig))) + Equals(_containingType, other._containingType) && + Equals(_methodNameAndSig, other._methodNameAndSig))) { return false; } @@ -1032,7 +1028,7 @@ public override bool Equals(object obj) if (other._args == null) return false; if (other._args.Length != _args.Length) return false; for (uint iArg = 0; _args != null && iArg < _args.Length; iArg++) - if (!Object.Equals(_args[iArg], other._args[iArg])) + if (!Equals(_args[iArg], other._args[iArg])) return false; } else if (other._args != null) @@ -1079,10 +1075,10 @@ public override bool Equals(object obj) if (other == null) return false; - if (!Object.Equals(other._containingType, _containingType)) + if (!Equals(other._containingType, _containingType)) return false; - if (!Object.Equals(other._name, _name)) + if (!Equals(other._name, _name)) return false; return true; @@ -1108,8 +1104,7 @@ public FixupSignature(FixupSignatureKind kind, Vertex signature) internal override void Save(NativeWriter writer) { writer.WriteUnsigned((uint)_kind); - if (_signature != null) - _signature.Save(writer); + _signature?.Save(writer); } public override int GetHashCode() @@ -1126,7 +1121,7 @@ public override bool Equals(object obj) if (other._kind != _kind) return false; - if (!Object.Equals(other._signature, _signature)) + if (!Equals(other._signature, _signature)) return false; return true; @@ -1166,7 +1161,7 @@ public override bool Equals(object obj) if (other == null) return false; - if (!Object.Equals(other._type, _type)) + if (!Equals(other._type, _type)) return false; if (other._staticDataKind != _staticDataKind) @@ -1209,7 +1204,7 @@ public override bool Equals(object obj) if (other == null) return false; - if (!Object.Equals(other._type, _type)) + if (!Equals(other._type, _type)) return false; if (other._slot != _slot) @@ -1273,13 +1268,13 @@ public override bool Equals(object obj) _callingConvention == other._callingConvention && _genericArgCount == other._genericArgCount && _parameters.Length == other._parameters.Length && - Object.Equals(_returnType, other._returnType))) + Equals(_returnType, other._returnType))) { return false; } for (int i = 0; i < _parameters.Length; i++) - if (!Object.Equals(_parameters[i], other._parameters[i])) + if (!Equals(_parameters[i], other._parameters[i])) return false; return true; @@ -1304,12 +1299,10 @@ public ModifierTypeSignature(TypeModifierKind modifier, Vertex param) internal override void Save(NativeWriter writer) { - NativeWriter.TypeSignatureCompressor compressor = new NativeWriter.TypeSignatureCompressor(writer); - writer.WriteUnsigned((uint)TypeSignatureKind.Modifier | ((uint)_modifier << 4)); _param.Save(writer); - compressor.Pack(this); + NativeWriter.TypeSignatureCompressor.Pack(this); } public override int GetHashCode() @@ -1323,7 +1316,7 @@ public override bool Equals(object obj) if (other == null) return false; - return _modifier == other._modifier && Object.Equals(_param, other._param); + return _modifier == other._modifier && Equals(_param, other._param); } } @@ -1343,11 +1336,9 @@ public VariableTypeSignature(uint index, bool method) internal override void Save(NativeWriter writer) { - NativeWriter.TypeSignatureCompressor compressor = new NativeWriter.TypeSignatureCompressor(writer); - writer.WriteUnsigned((uint)TypeSignatureKind.Variable | (_variableId << 4)); - compressor.Pack(this); + NativeWriter.TypeSignatureCompressor.Pack(this); } public override int GetHashCode() @@ -1383,14 +1374,12 @@ public InstantiationTypeSignature(Vertex typeDef, Vertex[] args) internal override void Save(NativeWriter writer) { - NativeWriter.TypeSignatureCompressor compressor = new NativeWriter.TypeSignatureCompressor(writer); - writer.WriteUnsigned((uint)TypeSignatureKind.Instantiation | ((uint)_args.Length << 4)); _typeDef.Save(writer); for (int iArg = 0; iArg < _args.Length; iArg++) _args[iArg].Save(writer); - compressor.Pack(this); + NativeWriter.TypeSignatureCompressor.Pack(this); } public override int GetHashCode() @@ -1409,11 +1398,11 @@ public override bool Equals(object obj) if (other == null) return false; - if (_args.Length != other._args.Length || !Object.Equals(_typeDef, other._typeDef)) + if (_args.Length != other._args.Length || !Equals(_typeDef, other._typeDef)) return false; for (uint iArg = 0; iArg < _args.Length; iArg++) - if (!Object.Equals(_args[iArg], other._args[iArg])) + if (!Equals(_args[iArg], other._args[iArg])) return false; return true; @@ -1444,8 +1433,6 @@ public MDArrayTypeSignature(Vertex arrayElementType, uint rank, uint[] bounds, u internal override void Save(NativeWriter writer) { - NativeWriter.TypeSignatureCompressor compressor = new NativeWriter.TypeSignatureCompressor(writer); - writer.WriteUnsigned((uint)TypeSignatureKind.MultiDimArray | ((uint)_rank << 4)); _arrayElementType.Save(writer); @@ -1457,7 +1444,7 @@ internal override void Save(NativeWriter writer) foreach (uint b in _lowerBounds) writer.WriteUnsigned(b); - compressor.Pack(this); + NativeWriter.TypeSignatureCompressor.Pack(this); } public override int GetHashCode() @@ -1479,7 +1466,7 @@ public override bool Equals(object obj) if (other == null) return false; - if (!Object.Equals(_arrayElementType, other._arrayElementType) || + if (!Equals(_arrayElementType, other._arrayElementType) || _rank != other._rank || _bounds.Length != other._bounds.Length || _lowerBounds.Length != other._lowerBounds.Length) @@ -1741,7 +1728,7 @@ class VertexArray : Vertex ///
private uint _entryIndexSize; - class VertexLeaf : Vertex + private sealed class VertexLeaf : Vertex { private Vertex _vertex; private int _leafIndex; @@ -1756,14 +1743,11 @@ internal override void Save(NativeWriter writer) { writer.WriteUnsigned((uint)_leafIndex << 2); - if (_vertex != null) - { - _vertex.Save(writer); - } + _vertex?.Save(writer); } } - class VertexTree : Vertex + private sealed class VertexTree : Vertex { private Vertex _first; private Vertex _second; @@ -1801,8 +1785,7 @@ internal override void Save(NativeWriter writer) writer.WriteUnsigned(value); - if (_first != null) - _first.Save(writer); + _first?.Save(writer); } } @@ -1830,7 +1813,7 @@ private Vertex ExpandBlock(int index, int depth, bool place, out bool isLeaf) if (first == null || second == null) { VertexLeaf leaf = new VertexLeaf( - first == null ? second : first, + first ?? second, (first == null ? index + 1 : index) & (BlockSize - 1)); if (place) @@ -1921,8 +1904,7 @@ public void ExpandLayout() VertexLeaf nullBlock = null; for (int i = 0; i < _entries.Count; i += BlockSize) { - bool isLeaf; - Vertex block = ExpandBlock(i, 4, true, out isLeaf); + Vertex block = ExpandBlock(i, 4, true, out _); if (block == null) { @@ -2009,7 +1991,7 @@ internal override void Save(NativeWriter writer) #endif class VertexHashtable : Vertex { - struct Entry + private struct Entry { public Entry(uint hashcode, Vertex vertex) { @@ -2059,7 +2041,7 @@ public void Append(uint hashcode, Vertex element) } // Returns 1 + log2(x) rounded up, 0 iff x == 0 - static int HighestBit(uint x) + private static int HighestBit(uint x) { int ret = 0; while (x != 0) @@ -2071,7 +2053,7 @@ static int HighestBit(uint x) } // Helper method to back patch entry index in the bucket table - static void PatchEntryIndex(NativeWriter writer, int patchOffset, int entryIndexSize, int entryIndex) + private static void PatchEntryIndex(NativeWriter writer, int patchOffset, int entryIndexSize, int entryIndex) { if (entryIndexSize == 0) { @@ -2091,7 +2073,7 @@ static void PatchEntryIndex(NativeWriter writer, int patchOffset, int entryIndex } } - void ComputeLayout() + private void ComputeLayout() { uint bucketsEstimate = (uint)(_Entries.Count / _nFillFactor); @@ -2117,7 +2099,6 @@ internal override void Save(NativeWriter writer) ComputeLayout(); int nEntries = _Entries.Count; - int startOffset = writer.GetCurrentOffset(); uint bucketMask = (_nBuckets - 1); // Lowest two bits are entry index size, the rest is log2 number of buckets diff --git a/src/coreclr/tools/Common/Internal/Runtime/CorConstants.cs b/src/coreclr/tools/Common/Internal/Runtime/CorConstants.cs index 5591b062f551e..9754321213b9d 100644 --- a/src/coreclr/tools/Common/Internal/Runtime/CorConstants.cs +++ b/src/coreclr/tools/Common/Internal/Runtime/CorConstants.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace Internal.CorConstants { public enum CorElementType : byte diff --git a/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs b/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs index a225665dcee12..db9e131861ca4 100644 --- a/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs +++ b/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Diagnostics; using Internal.TypeSystem; @@ -97,7 +96,9 @@ public static ushort ComputeFlags(TypeDesc type) // the rest of the padding data. // If paddings of greater than 7 bytes are necessary, then the high bits of the field represent that padding private const uint ValueTypePaddingLowMask = 0x7; +#pragma warning disable CA1823 // Avoid unused private fields private const uint ValueTypePaddingHighMask = 0xFFFFFF00; +#pragma warning restore CA1823 // Avoid unused private fields private const uint ValueTypePaddingMax = 0x07FFFFFF; private const int ValueTypePaddingHighShift = 8; private const uint ValueTypePaddingAlignmentMask = 0xF8; diff --git a/src/coreclr/tools/Common/Internal/Runtime/EETypeOptionalFieldsBuilder.cs b/src/coreclr/tools/Common/Internal/Runtime/EETypeOptionalFieldsBuilder.cs index 6481e6ef32cf5..e8d7f8407ec55 100644 --- a/src/coreclr/tools/Common/Internal/Runtime/EETypeOptionalFieldsBuilder.cs +++ b/src/coreclr/tools/Common/Internal/Runtime/EETypeOptionalFieldsBuilder.cs @@ -2,15 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Runtime.InteropServices; -using Internal.Runtime; using Internal.NativeFormat; using System.Diagnostics; using System.Text; namespace Internal.Runtime { - internal unsafe partial class EETypeOptionalFieldsBuilder + internal sealed unsafe partial class EETypeOptionalFieldsBuilder { private NativePrimitiveEncoder _encoder; private OptionalField[] _rgFields = new OptionalField[(int)EETypeOptionalFieldTag.Count]; @@ -18,17 +16,17 @@ internal unsafe partial class EETypeOptionalFieldsBuilder private struct OptionalField { internal bool _fieldPresent; - internal UInt32 _value; + internal uint _value; } internal EETypeOptionalFieldsBuilder() { } - internal UInt32 GetFieldValue(EETypeOptionalFieldTag eTag, UInt32 defaultValueIfNotFound) + internal uint GetFieldValue(EETypeOptionalFieldTag eTag, uint defaultValueIfNotFound) { return _rgFields[(int)eTag]._fieldPresent ? _rgFields[(int)eTag]._value : defaultValueIfNotFound; } - internal void SetFieldValue(EETypeOptionalFieldTag eTag, UInt32 value) + internal void SetFieldValue(EETypeOptionalFieldTag eTag, uint value) { _rgFields[(int)eTag]._fieldPresent = true; _rgFields[(int)eTag]._value = value; @@ -49,7 +47,7 @@ private int Encode() if (eLastTag == EETypeOptionalFieldTag.Count) return 0; - _encoder = new NativePrimitiveEncoder(); + _encoder = default(NativePrimitiveEncoder); _encoder.Init(); for (EETypeOptionalFieldTag eTag = 0; eTag < EETypeOptionalFieldTag.Count; eTag++) @@ -98,13 +96,13 @@ public override string ToString() } else { - sb.Append("x"); + sb.Append('x'); } if (i != (int)EETypeOptionalFieldTag.Count - 1) { - sb.Append("_"); + sb.Append('_'); } } diff --git a/src/coreclr/tools/Common/Internal/Runtime/GCDescEncoder.cs b/src/coreclr/tools/Common/Internal/Runtime/GCDescEncoder.cs index c842e61164ccf..207f67e1522cb 100644 --- a/src/coreclr/tools/Common/Internal/Runtime/GCDescEncoder.cs +++ b/src/coreclr/tools/Common/Internal/Runtime/GCDescEncoder.cs @@ -154,7 +154,7 @@ private static void EncodeAllGCPointersArrayGCDesc(ref T builder, int baseSiz where T : struct, ITargetBinaryWriter { // Construct the gc info as if this array contains exactly one pointer - // - the encoding trick where the size of the series is measured as a difference from + // - the encoding trick where the size of the series is measured as a difference from // total object size will make this work for arbitrary array lengths // Series size diff --git a/src/coreclr/tools/Common/Internal/Runtime/InterfaceDispatchCellCachePointerFlags.cs b/src/coreclr/tools/Common/Internal/Runtime/InterfaceDispatchCellCachePointerFlags.cs index a8fb3254fc2c0..bff58e834d218 100644 --- a/src/coreclr/tools/Common/Internal/Runtime/InterfaceDispatchCellCachePointerFlags.cs +++ b/src/coreclr/tools/Common/Internal/Runtime/InterfaceDispatchCellCachePointerFlags.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace Internal.Runtime { // diff --git a/src/coreclr/tools/Common/Internal/Runtime/ModuleHeaders.cs b/src/coreclr/tools/Common/Internal/Runtime/ModuleHeaders.cs index cc286f81b0361..4c5799acf72ba 100644 --- a/src/coreclr/tools/Common/Internal/Runtime/ModuleHeaders.cs +++ b/src/coreclr/tools/Common/Internal/Runtime/ModuleHeaders.cs @@ -17,7 +17,7 @@ internal struct ReadyToRunHeaderConstants public const ushort CurrentMajorVersion = 8; public const ushort CurrentMinorVersion = 0; } - +#if READYTORUN #pragma warning disable 0169 internal struct ReadyToRunHeader { @@ -34,6 +34,7 @@ internal struct ReadyToRunHeader // Array of sections follows. }; #pragma warning restore 0169 +#endif // // ReadyToRunSectionType IDs are used by the runtime to look up specific global data sections diff --git a/src/coreclr/tools/Common/Internal/Runtime/ReadyToRunConstants.cs b/src/coreclr/tools/Common/Internal/Runtime/ReadyToRunConstants.cs index b0126289eb7a9..15c02b57113ab 100644 --- a/src/coreclr/tools/Common/Internal/Runtime/ReadyToRunConstants.cs +++ b/src/coreclr/tools/Common/Internal/Runtime/ReadyToRunConstants.cs @@ -80,7 +80,7 @@ public enum ReadyToRunVirtualFunctionOverrideFlags : uint } [Flags] - enum ReadyToRunCrossModuleInlineFlags : uint + internal enum ReadyToRunCrossModuleInlineFlags : uint { CrossModuleInlinee = 0x1, HasCrossModuleInliners = 0x2, diff --git a/src/coreclr/tools/Common/Internal/Runtime/UniversalGenericParameterLayout.cs b/src/coreclr/tools/Common/Internal/Runtime/UniversalGenericParameterLayout.cs index d3d576972e6c4..47d9234f1fbf6 100644 --- a/src/coreclr/tools/Common/Internal/Runtime/UniversalGenericParameterLayout.cs +++ b/src/coreclr/tools/Common/Internal/Runtime/UniversalGenericParameterLayout.cs @@ -1,9 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Diagnostics; - using Internal.TypeSystem; namespace Internal.Runtime @@ -17,27 +14,27 @@ private enum HasVarsInvestigationLevel } /// - /// IF THESE SEMANTICS EVER CHANGE UPDATE THE LOGIC WHICH DEFINES THIS BEHAVIOR IN - /// THE DYNAMIC TYPE LOADER AS WELL AS THE COMPILER. + /// IF THESE SEMANTICS EVER CHANGE UPDATE THE LOGIC WHICH DEFINES THIS BEHAVIOR IN + /// THE DYNAMIC TYPE LOADER AS WELL AS THE COMPILER. /// (There is a version of this in TypeLoaderEnvironment.SignatureParsing.cs that must be kept in sync with this.) /// /// Parameter's are considered to have type layout dependent on their generic instantiation - /// if the type of the parameter in its signature is a type variable, or if the type is a generic + /// if the type of the parameter in its signature is a type variable, or if the type is a generic /// structure which meets 2 characteristics: /// 1. Structure size/layout is affected by the size/layout of one or more of its generic parameters /// 2. One or more of the generic parameters is a type variable, or a generic structure which also recursively /// would satisfy constraint 2. (Note, that in the recursion case, whether or not the structure is affected /// by the size/layout of its generic parameters is not investigated.) - /// + /// /// Examples parameter types, and behavior. - /// + /// /// T = true /// List[T] = false /// StructNotDependentOnArgsForSize[T] = false /// GenStructDependencyOnArgsForSize[T] = true /// StructNotDependentOnArgsForSize[GenStructDependencyOnArgsForSize[T]] = true /// StructNotDependentOnArgsForSize[GenStructDependencyOnArgsForSize[List[T]]]] = false - /// + /// /// Example non-parameter type behavior /// T = true /// List[T] = false diff --git a/src/coreclr/tools/Common/Internal/Text/Utf8String.cs b/src/coreclr/tools/Common/Internal/Text/Utf8String.cs index 9b44102c582c5..360aa3d27e943 100644 --- a/src/coreclr/tools/Common/Internal/Text/Utf8String.cs +++ b/src/coreclr/tools/Common/Internal/Text/Utf8String.cs @@ -3,7 +3,6 @@ using System; using System.Numerics; -using System.Runtime.CompilerServices; using System.Text; namespace Internal.Text @@ -43,7 +42,7 @@ public override bool Equals(object obj) return (obj is Utf8String) && Equals((Utf8String)obj); } - public unsafe override int GetHashCode() + public override unsafe int GetHashCode() { int length = _value.Length; uint hash = (uint)length; diff --git a/src/coreclr/tools/Common/Internal/Text/Utf8StringBuilder.cs b/src/coreclr/tools/Common/Internal/Text/Utf8StringBuilder.cs index a2144946a08ac..edf5b185b3c44 100644 --- a/src/coreclr/tools/Common/Internal/Text/Utf8StringBuilder.cs +++ b/src/coreclr/tools/Common/Internal/Text/Utf8StringBuilder.cs @@ -10,7 +10,7 @@ namespace Internal.Text public class Utf8StringBuilder { private byte[] _buffer = Array.Empty(); - private int _length = 0; + private int _length; public Utf8StringBuilder() { @@ -103,7 +103,7 @@ private void Grow(int extraSpace) _buffer = newBuffer; } - // Find the boundary of the last character prior to a position + // Find the boundary of the last character prior to a position // If pos points to the last byte of a char, then return pos; Otherwise, // return the position of the last byte of the preceding char. public int LastCharBoundary(int pos) diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs b/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs index 541c0dc424c55..2aa2105765b84 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs @@ -10,10 +10,10 @@ namespace Internal.JitInterface { - unsafe partial class CorInfoImpl + internal unsafe partial class CorInfoImpl { [UnmanagedCallersOnly] - static byte _isIntrinsic(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn) + private static byte _isIntrinsic(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn) { var _this = GetThis(thisHandle); try @@ -28,7 +28,7 @@ static byte _isIntrinsic(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_ } [UnmanagedCallersOnly] - static uint _getMethodAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn) + private static uint _getMethodAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn) { var _this = GetThis(thisHandle); try @@ -43,7 +43,7 @@ static uint _getMethodAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_ME } [UnmanagedCallersOnly] - static void _setMethodAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, CorInfoMethodRuntimeFlags attribs) + private static void _setMethodAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, CorInfoMethodRuntimeFlags attribs) { var _this = GetThis(thisHandle); try @@ -57,7 +57,7 @@ static void _setMethodAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_ME } [UnmanagedCallersOnly] - static void _getMethodSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, CORINFO_SIG_INFO* sig, CORINFO_CLASS_STRUCT_* memberParent) + private static void _getMethodSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, CORINFO_SIG_INFO* sig, CORINFO_CLASS_STRUCT_* memberParent) { var _this = GetThis(thisHandle); try @@ -71,7 +71,7 @@ static void _getMethodSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD } [UnmanagedCallersOnly] - static byte _getMethodInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, CORINFO_METHOD_INFO* info) + private static byte _getMethodInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, CORINFO_METHOD_INFO* info) { var _this = GetThis(thisHandle); try @@ -86,7 +86,7 @@ static byte _getMethodInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHO } [UnmanagedCallersOnly] - static CorInfoInline _canInline(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* callerHnd, CORINFO_METHOD_STRUCT_* calleeHnd) + private static CorInfoInline _canInline(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* callerHnd, CORINFO_METHOD_STRUCT_* calleeHnd) { var _this = GetThis(thisHandle); try @@ -101,7 +101,7 @@ static CorInfoInline _canInline(IntPtr thisHandle, IntPtr* ppException, CORINFO_ } [UnmanagedCallersOnly] - static void _beginInlining(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* inlinerHnd, CORINFO_METHOD_STRUCT_* inlineeHnd) + private static void _beginInlining(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* inlinerHnd, CORINFO_METHOD_STRUCT_* inlineeHnd) { var _this = GetThis(thisHandle); try @@ -115,7 +115,7 @@ static void _beginInlining(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHO } [UnmanagedCallersOnly] - static void _reportInliningDecision(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* inlinerHnd, CORINFO_METHOD_STRUCT_* inlineeHnd, CorInfoInline inlineResult, byte* reason) + private static void _reportInliningDecision(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* inlinerHnd, CORINFO_METHOD_STRUCT_* inlineeHnd, CorInfoInline inlineResult, byte* reason) { var _this = GetThis(thisHandle); try @@ -129,7 +129,7 @@ static void _reportInliningDecision(IntPtr thisHandle, IntPtr* ppException, CORI } [UnmanagedCallersOnly] - static byte _canTailCall(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* callerHnd, CORINFO_METHOD_STRUCT_* declaredCalleeHnd, CORINFO_METHOD_STRUCT_* exactCalleeHnd, byte fIsTailPrefix) + private static byte _canTailCall(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* callerHnd, CORINFO_METHOD_STRUCT_* declaredCalleeHnd, CORINFO_METHOD_STRUCT_* exactCalleeHnd, byte fIsTailPrefix) { var _this = GetThis(thisHandle); try @@ -144,7 +144,7 @@ static byte _canTailCall(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_ } [UnmanagedCallersOnly] - static void _reportTailCallDecision(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* callerHnd, CORINFO_METHOD_STRUCT_* calleeHnd, byte fIsTailPrefix, CorInfoTailCall tailCallResult, byte* reason) + private static void _reportTailCallDecision(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* callerHnd, CORINFO_METHOD_STRUCT_* calleeHnd, byte fIsTailPrefix, CorInfoTailCall tailCallResult, byte* reason) { var _this = GetThis(thisHandle); try @@ -158,7 +158,7 @@ static void _reportTailCallDecision(IntPtr thisHandle, IntPtr* ppException, CORI } [UnmanagedCallersOnly] - static void _getEHinfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint EHnumber, CORINFO_EH_CLAUSE* clause) + private static void _getEHinfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint EHnumber, CORINFO_EH_CLAUSE* clause) { var _this = GetThis(thisHandle); try @@ -172,7 +172,7 @@ static void _getEHinfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_ST } [UnmanagedCallersOnly] - static CORINFO_CLASS_STRUCT_* _getMethodClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method) + private static CORINFO_CLASS_STRUCT_* _getMethodClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method) { var _this = GetThis(thisHandle); try @@ -187,7 +187,7 @@ static void _getEHinfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_ST } [UnmanagedCallersOnly] - static CORINFO_MODULE_STRUCT_* _getMethodModule(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method) + private static CORINFO_MODULE_STRUCT_* _getMethodModule(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method) { var _this = GetThis(thisHandle); try @@ -202,7 +202,7 @@ static void _getEHinfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_ST } [UnmanagedCallersOnly] - static void _getMethodVTableOffset(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, uint* offsetOfIndirection, uint* offsetAfterIndirection, bool* isRelative) + private static void _getMethodVTableOffset(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, uint* offsetOfIndirection, uint* offsetAfterIndirection, bool* isRelative) { var _this = GetThis(thisHandle); try @@ -216,7 +216,7 @@ static void _getMethodVTableOffset(IntPtr thisHandle, IntPtr* ppException, CORIN } [UnmanagedCallersOnly] - static byte _resolveVirtualMethod(IntPtr thisHandle, IntPtr* ppException, CORINFO_DEVIRTUALIZATION_INFO* info) + private static byte _resolveVirtualMethod(IntPtr thisHandle, IntPtr* ppException, CORINFO_DEVIRTUALIZATION_INFO* info) { var _this = GetThis(thisHandle); try @@ -231,7 +231,7 @@ static byte _resolveVirtualMethod(IntPtr thisHandle, IntPtr* ppException, CORINF } [UnmanagedCallersOnly] - static CORINFO_METHOD_STRUCT_* _getUnboxedEntry(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, bool* requiresInstMethodTableArg) + private static CORINFO_METHOD_STRUCT_* _getUnboxedEntry(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, bool* requiresInstMethodTableArg) { var _this = GetThis(thisHandle); try @@ -246,7 +246,7 @@ static byte _resolveVirtualMethod(IntPtr thisHandle, IntPtr* ppException, CORINF } [UnmanagedCallersOnly] - static CORINFO_CLASS_STRUCT_* _getDefaultComparerClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* elemType) + private static CORINFO_CLASS_STRUCT_* _getDefaultComparerClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* elemType) { var _this = GetThis(thisHandle); try @@ -261,7 +261,7 @@ static byte _resolveVirtualMethod(IntPtr thisHandle, IntPtr* ppException, CORINF } [UnmanagedCallersOnly] - static CORINFO_CLASS_STRUCT_* _getDefaultEqualityComparerClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* elemType) + private static CORINFO_CLASS_STRUCT_* _getDefaultEqualityComparerClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* elemType) { var _this = GetThis(thisHandle); try @@ -276,7 +276,7 @@ static byte _resolveVirtualMethod(IntPtr thisHandle, IntPtr* ppException, CORINF } [UnmanagedCallersOnly] - static void _expandRawHandleIntrinsic(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_GENERICHANDLE_RESULT* pResult) + private static void _expandRawHandleIntrinsic(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_GENERICHANDLE_RESULT* pResult) { var _this = GetThis(thisHandle); try @@ -290,7 +290,7 @@ static void _expandRawHandleIntrinsic(IntPtr thisHandle, IntPtr* ppException, CO } [UnmanagedCallersOnly] - static byte _isIntrinsicType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* classHnd) + private static byte _isIntrinsicType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* classHnd) { var _this = GetThis(thisHandle); try @@ -305,7 +305,7 @@ static byte _isIntrinsicType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLA } [UnmanagedCallersOnly] - static CorInfoCallConvExtension _getUnmanagedCallConv(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, CORINFO_SIG_INFO* callSiteSig, bool* pSuppressGCTransition) + private static CorInfoCallConvExtension _getUnmanagedCallConv(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, CORINFO_SIG_INFO* callSiteSig, bool* pSuppressGCTransition) { var _this = GetThis(thisHandle); try @@ -320,7 +320,7 @@ static CorInfoCallConvExtension _getUnmanagedCallConv(IntPtr thisHandle, IntPtr* } [UnmanagedCallersOnly] - static byte _pInvokeMarshalingRequired(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, CORINFO_SIG_INFO* callSiteSig) + private static byte _pInvokeMarshalingRequired(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, CORINFO_SIG_INFO* callSiteSig) { var _this = GetThis(thisHandle); try @@ -335,7 +335,7 @@ static byte _pInvokeMarshalingRequired(IntPtr thisHandle, IntPtr* ppException, C } [UnmanagedCallersOnly] - static byte _satisfiesMethodConstraints(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* parent, CORINFO_METHOD_STRUCT_* method) + private static byte _satisfiesMethodConstraints(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* parent, CORINFO_METHOD_STRUCT_* method) { var _this = GetThis(thisHandle); try @@ -350,7 +350,7 @@ static byte _satisfiesMethodConstraints(IntPtr thisHandle, IntPtr* ppException, } [UnmanagedCallersOnly] - static byte _isCompatibleDelegate(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* objCls, CORINFO_CLASS_STRUCT_* methodParentCls, CORINFO_METHOD_STRUCT_* method, CORINFO_CLASS_STRUCT_* delegateCls, bool* pfIsOpenDelegate) + private static byte _isCompatibleDelegate(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* objCls, CORINFO_CLASS_STRUCT_* methodParentCls, CORINFO_METHOD_STRUCT_* method, CORINFO_CLASS_STRUCT_* delegateCls, bool* pfIsOpenDelegate) { var _this = GetThis(thisHandle); try @@ -365,7 +365,7 @@ static byte _isCompatibleDelegate(IntPtr thisHandle, IntPtr* ppException, CORINF } [UnmanagedCallersOnly] - static void _methodMustBeLoadedBeforeCodeIsRun(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method) + private static void _methodMustBeLoadedBeforeCodeIsRun(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method) { var _this = GetThis(thisHandle); try @@ -379,7 +379,7 @@ static void _methodMustBeLoadedBeforeCodeIsRun(IntPtr thisHandle, IntPtr* ppExce } [UnmanagedCallersOnly] - static CORINFO_METHOD_STRUCT_* _mapMethodDeclToMethodImpl(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method) + private static CORINFO_METHOD_STRUCT_* _mapMethodDeclToMethodImpl(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method) { var _this = GetThis(thisHandle); try @@ -394,7 +394,7 @@ static void _methodMustBeLoadedBeforeCodeIsRun(IntPtr thisHandle, IntPtr* ppExce } [UnmanagedCallersOnly] - static void _getGSCookie(IntPtr thisHandle, IntPtr* ppException, IntPtr* pCookieVal, IntPtr** ppCookieVal) + private static void _getGSCookie(IntPtr thisHandle, IntPtr* ppException, IntPtr* pCookieVal, IntPtr** ppCookieVal) { var _this = GetThis(thisHandle); try @@ -408,7 +408,7 @@ static void _getGSCookie(IntPtr thisHandle, IntPtr* ppException, IntPtr* pCookie } [UnmanagedCallersOnly] - static void _setPatchpointInfo(IntPtr thisHandle, IntPtr* ppException, PatchpointInfo* patchpointInfo) + private static void _setPatchpointInfo(IntPtr thisHandle, IntPtr* ppException, PatchpointInfo* patchpointInfo) { var _this = GetThis(thisHandle); try @@ -422,7 +422,7 @@ static void _setPatchpointInfo(IntPtr thisHandle, IntPtr* ppException, Patchpoin } [UnmanagedCallersOnly] - static PatchpointInfo* _getOSRInfo(IntPtr thisHandle, IntPtr* ppException, uint* ilOffset) + private static PatchpointInfo* _getOSRInfo(IntPtr thisHandle, IntPtr* ppException, uint* ilOffset) { var _this = GetThis(thisHandle); try @@ -437,7 +437,7 @@ static void _setPatchpointInfo(IntPtr thisHandle, IntPtr* ppException, Patchpoin } [UnmanagedCallersOnly] - static void _resolveToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken) + private static void _resolveToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken) { var _this = GetThis(thisHandle); try @@ -451,7 +451,7 @@ static void _resolveToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLV } [UnmanagedCallersOnly] - static byte _tryResolveToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken) + private static byte _tryResolveToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken) { var _this = GetThis(thisHandle); try @@ -466,7 +466,7 @@ static byte _tryResolveToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_RES } [UnmanagedCallersOnly] - static void _findSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint sigTOK, CORINFO_CONTEXT_STRUCT* context, CORINFO_SIG_INFO* sig) + private static void _findSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint sigTOK, CORINFO_CONTEXT_STRUCT* context, CORINFO_SIG_INFO* sig) { var _this = GetThis(thisHandle); try @@ -480,7 +480,7 @@ static void _findSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRU } [UnmanagedCallersOnly] - static void _findCallSiteSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint methTOK, CORINFO_CONTEXT_STRUCT* context, CORINFO_SIG_INFO* sig) + private static void _findCallSiteSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint methTOK, CORINFO_CONTEXT_STRUCT* context, CORINFO_SIG_INFO* sig) { var _this = GetThis(thisHandle); try @@ -494,7 +494,7 @@ static void _findCallSiteSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_MOD } [UnmanagedCallersOnly] - static CORINFO_CLASS_STRUCT_* _getTokenTypeAsHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken) + private static CORINFO_CLASS_STRUCT_* _getTokenTypeAsHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken) { var _this = GetThis(thisHandle); try @@ -509,7 +509,7 @@ static void _findCallSiteSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_MOD } [UnmanagedCallersOnly] - static byte _isValidToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint metaTOK) + private static byte _isValidToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint metaTOK) { var _this = GetThis(thisHandle); try @@ -524,7 +524,7 @@ static byte _isValidToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE } [UnmanagedCallersOnly] - static byte _isValidStringRef(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint metaTOK) + private static byte _isValidStringRef(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint metaTOK) { var _this = GetThis(thisHandle); try @@ -539,7 +539,7 @@ static byte _isValidStringRef(IntPtr thisHandle, IntPtr* ppException, CORINFO_MO } [UnmanagedCallersOnly] - static int _getStringLiteral(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint metaTOK, char* buffer, int bufferSize) + private static int _getStringLiteral(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, uint metaTOK, char* buffer, int bufferSize) { var _this = GetThis(thisHandle); try @@ -554,7 +554,7 @@ static int _getStringLiteral(IntPtr thisHandle, IntPtr* ppException, CORINFO_MOD } [UnmanagedCallersOnly] - static CorInfoType _asCorInfoType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static CorInfoType _asCorInfoType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -569,7 +569,7 @@ static CorInfoType _asCorInfoType(IntPtr thisHandle, IntPtr* ppException, CORINF } [UnmanagedCallersOnly] - static byte* _getClassName(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static byte* _getClassName(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -584,7 +584,7 @@ static CorInfoType _asCorInfoType(IntPtr thisHandle, IntPtr* ppException, CORINF } [UnmanagedCallersOnly] - static byte* _getClassNameFromMetadata(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, byte** namespaceName) + private static byte* _getClassNameFromMetadata(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, byte** namespaceName) { var _this = GetThis(thisHandle); try @@ -599,7 +599,7 @@ static CorInfoType _asCorInfoType(IntPtr thisHandle, IntPtr* ppException, CORINF } [UnmanagedCallersOnly] - static CORINFO_CLASS_STRUCT_* _getTypeInstantiationArgument(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, uint index) + private static CORINFO_CLASS_STRUCT_* _getTypeInstantiationArgument(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, uint index) { var _this = GetThis(thisHandle); try @@ -614,7 +614,7 @@ static CorInfoType _asCorInfoType(IntPtr thisHandle, IntPtr* ppException, CORINF } [UnmanagedCallersOnly] - static int _appendClassName(IntPtr thisHandle, IntPtr* ppException, char** ppBuf, int* pnBufLen, CORINFO_CLASS_STRUCT_* cls, byte fNamespace, byte fFullInst, byte fAssembly) + private static int _appendClassName(IntPtr thisHandle, IntPtr* ppException, char** ppBuf, int* pnBufLen, CORINFO_CLASS_STRUCT_* cls, byte fNamespace, byte fFullInst, byte fAssembly) { var _this = GetThis(thisHandle); try @@ -629,7 +629,7 @@ static int _appendClassName(IntPtr thisHandle, IntPtr* ppException, char** ppBuf } [UnmanagedCallersOnly] - static byte _isValueClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static byte _isValueClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -644,7 +644,7 @@ static byte _isValueClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_ } [UnmanagedCallersOnly] - static CorInfoInlineTypeCheck _canInlineTypeCheck(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, CorInfoInlineTypeCheckSource source) + private static CorInfoInlineTypeCheck _canInlineTypeCheck(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, CorInfoInlineTypeCheckSource source) { var _this = GetThis(thisHandle); try @@ -659,7 +659,7 @@ static CorInfoInlineTypeCheck _canInlineTypeCheck(IntPtr thisHandle, IntPtr* ppE } [UnmanagedCallersOnly] - static uint _getClassAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static uint _getClassAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -674,7 +674,7 @@ static uint _getClassAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLA } [UnmanagedCallersOnly] - static CORINFO_MODULE_STRUCT_* _getClassModule(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static CORINFO_MODULE_STRUCT_* _getClassModule(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -689,7 +689,7 @@ static uint _getClassAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLA } [UnmanagedCallersOnly] - static CORINFO_ASSEMBLY_STRUCT_* _getModuleAssembly(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* mod) + private static CORINFO_ASSEMBLY_STRUCT_* _getModuleAssembly(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* mod) { var _this = GetThis(thisHandle); try @@ -704,7 +704,7 @@ static uint _getClassAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLA } [UnmanagedCallersOnly] - static byte* _getAssemblyName(IntPtr thisHandle, IntPtr* ppException, CORINFO_ASSEMBLY_STRUCT_* assem) + private static byte* _getAssemblyName(IntPtr thisHandle, IntPtr* ppException, CORINFO_ASSEMBLY_STRUCT_* assem) { var _this = GetThis(thisHandle); try @@ -719,7 +719,7 @@ static uint _getClassAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLA } [UnmanagedCallersOnly] - static void* _LongLifetimeMalloc(IntPtr thisHandle, IntPtr* ppException, UIntPtr sz) + private static void* _LongLifetimeMalloc(IntPtr thisHandle, IntPtr* ppException, UIntPtr sz) { var _this = GetThis(thisHandle); try @@ -734,7 +734,7 @@ static uint _getClassAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLA } [UnmanagedCallersOnly] - static void _LongLifetimeFree(IntPtr thisHandle, IntPtr* ppException, void* obj) + private static void _LongLifetimeFree(IntPtr thisHandle, IntPtr* ppException, void* obj) { var _this = GetThis(thisHandle); try @@ -748,7 +748,7 @@ static void _LongLifetimeFree(IntPtr thisHandle, IntPtr* ppException, void* obj) } [UnmanagedCallersOnly] - static UIntPtr _getClassModuleIdForStatics(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, CORINFO_MODULE_STRUCT_** pModule, void** ppIndirection) + private static UIntPtr _getClassModuleIdForStatics(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, CORINFO_MODULE_STRUCT_** pModule, void** ppIndirection) { var _this = GetThis(thisHandle); try @@ -763,7 +763,7 @@ static UIntPtr _getClassModuleIdForStatics(IntPtr thisHandle, IntPtr* ppExceptio } [UnmanagedCallersOnly] - static uint _getClassSize(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static uint _getClassSize(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -778,7 +778,7 @@ static uint _getClassSize(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_ } [UnmanagedCallersOnly] - static uint _getHeapClassSize(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static uint _getHeapClassSize(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -793,7 +793,7 @@ static uint _getHeapClassSize(IntPtr thisHandle, IntPtr* ppException, CORINFO_CL } [UnmanagedCallersOnly] - static byte _canAllocateOnStack(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static byte _canAllocateOnStack(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -808,7 +808,7 @@ static byte _canAllocateOnStack(IntPtr thisHandle, IntPtr* ppException, CORINFO_ } [UnmanagedCallersOnly] - static uint _getClassAlignmentRequirement(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, byte fDoubleAlignHint) + private static uint _getClassAlignmentRequirement(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, byte fDoubleAlignHint) { var _this = GetThis(thisHandle); try @@ -823,7 +823,7 @@ static uint _getClassAlignmentRequirement(IntPtr thisHandle, IntPtr* ppException } [UnmanagedCallersOnly] - static uint _getClassGClayout(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, byte* gcPtrs) + private static uint _getClassGClayout(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, byte* gcPtrs) { var _this = GetThis(thisHandle); try @@ -838,7 +838,7 @@ static uint _getClassGClayout(IntPtr thisHandle, IntPtr* ppException, CORINFO_CL } [UnmanagedCallersOnly] - static uint _getClassNumInstanceFields(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static uint _getClassNumInstanceFields(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -853,7 +853,7 @@ static uint _getClassNumInstanceFields(IntPtr thisHandle, IntPtr* ppException, C } [UnmanagedCallersOnly] - static CORINFO_FIELD_STRUCT_* _getFieldInClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* clsHnd, int num) + private static CORINFO_FIELD_STRUCT_* _getFieldInClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* clsHnd, int num) { var _this = GetThis(thisHandle); try @@ -868,7 +868,7 @@ static uint _getClassNumInstanceFields(IntPtr thisHandle, IntPtr* ppException, C } [UnmanagedCallersOnly] - static byte _checkMethodModifier(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* hMethod, byte* modifier, byte fOptional) + private static byte _checkMethodModifier(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* hMethod, byte* modifier, byte fOptional) { var _this = GetThis(thisHandle); try @@ -883,7 +883,7 @@ static byte _checkMethodModifier(IntPtr thisHandle, IntPtr* ppException, CORINFO } [UnmanagedCallersOnly] - static CorInfoHelpFunc _getNewHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, bool* pHasSideEffects) + private static CorInfoHelpFunc _getNewHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, bool* pHasSideEffects) { var _this = GetThis(thisHandle); try @@ -898,7 +898,7 @@ static CorInfoHelpFunc _getNewHelper(IntPtr thisHandle, IntPtr* ppException, COR } [UnmanagedCallersOnly] - static CorInfoHelpFunc _getNewArrHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* arrayCls) + private static CorInfoHelpFunc _getNewArrHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* arrayCls) { var _this = GetThis(thisHandle); try @@ -913,7 +913,7 @@ static CorInfoHelpFunc _getNewArrHelper(IntPtr thisHandle, IntPtr* ppException, } [UnmanagedCallersOnly] - static CorInfoHelpFunc _getCastingHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, byte fThrowing) + private static CorInfoHelpFunc _getCastingHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, byte fThrowing) { var _this = GetThis(thisHandle); try @@ -928,7 +928,7 @@ static CorInfoHelpFunc _getCastingHelper(IntPtr thisHandle, IntPtr* ppException, } [UnmanagedCallersOnly] - static CorInfoHelpFunc _getSharedCCtorHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* clsHnd) + private static CorInfoHelpFunc _getSharedCCtorHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* clsHnd) { var _this = GetThis(thisHandle); try @@ -943,7 +943,7 @@ static CorInfoHelpFunc _getSharedCCtorHelper(IntPtr thisHandle, IntPtr* ppExcept } [UnmanagedCallersOnly] - static CORINFO_CLASS_STRUCT_* _getTypeForBox(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static CORINFO_CLASS_STRUCT_* _getTypeForBox(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -958,7 +958,7 @@ static CorInfoHelpFunc _getSharedCCtorHelper(IntPtr thisHandle, IntPtr* ppExcept } [UnmanagedCallersOnly] - static CorInfoHelpFunc _getBoxHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static CorInfoHelpFunc _getBoxHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -973,7 +973,7 @@ static CorInfoHelpFunc _getBoxHelper(IntPtr thisHandle, IntPtr* ppException, COR } [UnmanagedCallersOnly] - static CorInfoHelpFunc _getUnBoxHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static CorInfoHelpFunc _getUnBoxHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -988,7 +988,7 @@ static CorInfoHelpFunc _getUnBoxHelper(IntPtr thisHandle, IntPtr* ppException, C } [UnmanagedCallersOnly] - static byte _getReadyToRunHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_LOOKUP_KIND* pGenericLookupKind, CorInfoHelpFunc id, CORINFO_CONST_LOOKUP* pLookup) + private static byte _getReadyToRunHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_LOOKUP_KIND* pGenericLookupKind, CorInfoHelpFunc id, CORINFO_CONST_LOOKUP* pLookup) { var _this = GetThis(thisHandle); try @@ -1003,7 +1003,7 @@ static byte _getReadyToRunHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO } [UnmanagedCallersOnly] - static void _getReadyToRunDelegateCtorHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pTargetMethod, mdToken targetConstraint, CORINFO_CLASS_STRUCT_* delegateType, CORINFO_LOOKUP* pLookup) + private static void _getReadyToRunDelegateCtorHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pTargetMethod, mdToken targetConstraint, CORINFO_CLASS_STRUCT_* delegateType, CORINFO_LOOKUP* pLookup) { var _this = GetThis(thisHandle); try @@ -1017,7 +1017,7 @@ static void _getReadyToRunDelegateCtorHelper(IntPtr thisHandle, IntPtr* ppExcept } [UnmanagedCallersOnly] - static byte* _getHelperName(IntPtr thisHandle, IntPtr* ppException, CorInfoHelpFunc helpFunc) + private static byte* _getHelperName(IntPtr thisHandle, IntPtr* ppException, CorInfoHelpFunc helpFunc) { var _this = GetThis(thisHandle); try @@ -1032,7 +1032,7 @@ static void _getReadyToRunDelegateCtorHelper(IntPtr thisHandle, IntPtr* ppExcept } [UnmanagedCallersOnly] - static CorInfoInitClassResult _initClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, CORINFO_METHOD_STRUCT_* method, CORINFO_CONTEXT_STRUCT* context) + private static CorInfoInitClassResult _initClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, CORINFO_METHOD_STRUCT_* method, CORINFO_CONTEXT_STRUCT* context) { var _this = GetThis(thisHandle); try @@ -1047,7 +1047,7 @@ static CorInfoInitClassResult _initClass(IntPtr thisHandle, IntPtr* ppException, } [UnmanagedCallersOnly] - static void _classMustBeLoadedBeforeCodeIsRun(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static void _classMustBeLoadedBeforeCodeIsRun(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -1061,7 +1061,7 @@ static void _classMustBeLoadedBeforeCodeIsRun(IntPtr thisHandle, IntPtr* ppExcep } [UnmanagedCallersOnly] - static CORINFO_CLASS_STRUCT_* _getBuiltinClass(IntPtr thisHandle, IntPtr* ppException, CorInfoClassId classId) + private static CORINFO_CLASS_STRUCT_* _getBuiltinClass(IntPtr thisHandle, IntPtr* ppException, CorInfoClassId classId) { var _this = GetThis(thisHandle); try @@ -1076,7 +1076,7 @@ static void _classMustBeLoadedBeforeCodeIsRun(IntPtr thisHandle, IntPtr* ppExcep } [UnmanagedCallersOnly] - static CorInfoType _getTypeForPrimitiveValueClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static CorInfoType _getTypeForPrimitiveValueClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -1091,7 +1091,7 @@ static CorInfoType _getTypeForPrimitiveValueClass(IntPtr thisHandle, IntPtr* ppE } [UnmanagedCallersOnly] - static CorInfoType _getTypeForPrimitiveNumericClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static CorInfoType _getTypeForPrimitiveNumericClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -1106,7 +1106,7 @@ static CorInfoType _getTypeForPrimitiveNumericClass(IntPtr thisHandle, IntPtr* p } [UnmanagedCallersOnly] - static byte _canCast(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* child, CORINFO_CLASS_STRUCT_* parent) + private static byte _canCast(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* child, CORINFO_CLASS_STRUCT_* parent) { var _this = GetThis(thisHandle); try @@ -1121,7 +1121,7 @@ static byte _canCast(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUC } [UnmanagedCallersOnly] - static byte _areTypesEquivalent(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls1, CORINFO_CLASS_STRUCT_* cls2) + private static byte _areTypesEquivalent(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls1, CORINFO_CLASS_STRUCT_* cls2) { var _this = GetThis(thisHandle); try @@ -1136,7 +1136,7 @@ static byte _areTypesEquivalent(IntPtr thisHandle, IntPtr* ppException, CORINFO_ } [UnmanagedCallersOnly] - static TypeCompareState _compareTypesForCast(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* fromClass, CORINFO_CLASS_STRUCT_* toClass) + private static TypeCompareState _compareTypesForCast(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* fromClass, CORINFO_CLASS_STRUCT_* toClass) { var _this = GetThis(thisHandle); try @@ -1151,7 +1151,7 @@ static TypeCompareState _compareTypesForCast(IntPtr thisHandle, IntPtr* ppExcept } [UnmanagedCallersOnly] - static TypeCompareState _compareTypesForEquality(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls1, CORINFO_CLASS_STRUCT_* cls2) + private static TypeCompareState _compareTypesForEquality(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls1, CORINFO_CLASS_STRUCT_* cls2) { var _this = GetThis(thisHandle); try @@ -1166,7 +1166,7 @@ static TypeCompareState _compareTypesForEquality(IntPtr thisHandle, IntPtr* ppEx } [UnmanagedCallersOnly] - static CORINFO_CLASS_STRUCT_* _mergeClasses(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls1, CORINFO_CLASS_STRUCT_* cls2) + private static CORINFO_CLASS_STRUCT_* _mergeClasses(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls1, CORINFO_CLASS_STRUCT_* cls2) { var _this = GetThis(thisHandle); try @@ -1181,7 +1181,7 @@ static TypeCompareState _compareTypesForEquality(IntPtr thisHandle, IntPtr* ppEx } [UnmanagedCallersOnly] - static byte _isMoreSpecificType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls1, CORINFO_CLASS_STRUCT_* cls2) + private static byte _isMoreSpecificType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls1, CORINFO_CLASS_STRUCT_* cls2) { var _this = GetThis(thisHandle); try @@ -1196,7 +1196,7 @@ static byte _isMoreSpecificType(IntPtr thisHandle, IntPtr* ppException, CORINFO_ } [UnmanagedCallersOnly] - static CORINFO_CLASS_STRUCT_* _getParentType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static CORINFO_CLASS_STRUCT_* _getParentType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -1211,7 +1211,7 @@ static byte _isMoreSpecificType(IntPtr thisHandle, IntPtr* ppException, CORINFO_ } [UnmanagedCallersOnly] - static CorInfoType _getChildType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* clsHnd, CORINFO_CLASS_STRUCT_** clsRet) + private static CorInfoType _getChildType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* clsHnd, CORINFO_CLASS_STRUCT_** clsRet) { var _this = GetThis(thisHandle); try @@ -1226,7 +1226,7 @@ static CorInfoType _getChildType(IntPtr thisHandle, IntPtr* ppException, CORINFO } [UnmanagedCallersOnly] - static byte _satisfiesClassConstraints(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static byte _satisfiesClassConstraints(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -1241,7 +1241,7 @@ static byte _satisfiesClassConstraints(IntPtr thisHandle, IntPtr* ppException, C } [UnmanagedCallersOnly] - static byte _isSDArray(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static byte _isSDArray(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -1256,7 +1256,7 @@ static byte _isSDArray(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STR } [UnmanagedCallersOnly] - static uint _getArrayRank(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static uint _getArrayRank(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -1271,7 +1271,7 @@ static uint _getArrayRank(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_ } [UnmanagedCallersOnly] - static CorInfoArrayIntrinsic _getArrayIntrinsicID(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn) + private static CorInfoArrayIntrinsic _getArrayIntrinsicID(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn) { var _this = GetThis(thisHandle); try @@ -1286,7 +1286,7 @@ static CorInfoArrayIntrinsic _getArrayIntrinsicID(IntPtr thisHandle, IntPtr* ppE } [UnmanagedCallersOnly] - static void* _getArrayInitializationData(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, uint size) + private static void* _getArrayInitializationData(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, uint size) { var _this = GetThis(thisHandle); try @@ -1301,7 +1301,7 @@ static CorInfoArrayIntrinsic _getArrayIntrinsicID(IntPtr thisHandle, IntPtr* ppE } [UnmanagedCallersOnly] - static CorInfoIsAccessAllowedResult _canAccessClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_HELPER_DESC* pAccessHelper) + private static CorInfoIsAccessAllowedResult _canAccessClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_HELPER_DESC* pAccessHelper) { var _this = GetThis(thisHandle); try @@ -1316,7 +1316,7 @@ static CorInfoIsAccessAllowedResult _canAccessClass(IntPtr thisHandle, IntPtr* p } [UnmanagedCallersOnly] - static byte* _getFieldName(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* ftn, byte** moduleName) + private static byte* _getFieldName(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* ftn, byte** moduleName) { var _this = GetThis(thisHandle); try @@ -1331,7 +1331,7 @@ static CorInfoIsAccessAllowedResult _canAccessClass(IntPtr thisHandle, IntPtr* p } [UnmanagedCallersOnly] - static CORINFO_CLASS_STRUCT_* _getFieldClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field) + private static CORINFO_CLASS_STRUCT_* _getFieldClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field) { var _this = GetThis(thisHandle); try @@ -1346,7 +1346,7 @@ static CorInfoIsAccessAllowedResult _canAccessClass(IntPtr thisHandle, IntPtr* p } [UnmanagedCallersOnly] - static CorInfoType _getFieldType(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, CORINFO_CLASS_STRUCT_** structType, CORINFO_CLASS_STRUCT_* memberParent) + private static CorInfoType _getFieldType(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, CORINFO_CLASS_STRUCT_** structType, CORINFO_CLASS_STRUCT_* memberParent) { var _this = GetThis(thisHandle); try @@ -1361,7 +1361,7 @@ static CorInfoType _getFieldType(IntPtr thisHandle, IntPtr* ppException, CORINFO } [UnmanagedCallersOnly] - static uint _getFieldOffset(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field) + private static uint _getFieldOffset(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field) { var _this = GetThis(thisHandle); try @@ -1376,7 +1376,7 @@ static uint _getFieldOffset(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIEL } [UnmanagedCallersOnly] - static void _getFieldInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_ACCESS_FLAGS flags, CORINFO_FIELD_INFO* pResult) + private static void _getFieldInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_ACCESS_FLAGS flags, CORINFO_FIELD_INFO* pResult) { var _this = GetThis(thisHandle); try @@ -1390,7 +1390,7 @@ static void _getFieldInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLV } [UnmanagedCallersOnly] - static byte _isFieldStatic(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* fldHnd) + private static byte _isFieldStatic(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* fldHnd) { var _this = GetThis(thisHandle); try @@ -1405,7 +1405,7 @@ static byte _isFieldStatic(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD } [UnmanagedCallersOnly] - static void _getBoundaries(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint* cILOffsets, uint** pILOffsets, BoundaryTypes* implicitBoundaries) + private static void _getBoundaries(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint* cILOffsets, uint** pILOffsets, BoundaryTypes* implicitBoundaries) { var _this = GetThis(thisHandle); try @@ -1419,7 +1419,7 @@ static void _getBoundaries(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHO } [UnmanagedCallersOnly] - static void _setBoundaries(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint cMap, OffsetMapping* pMap) + private static void _setBoundaries(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint cMap, OffsetMapping* pMap) { var _this = GetThis(thisHandle); try @@ -1433,7 +1433,7 @@ static void _setBoundaries(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHO } [UnmanagedCallersOnly] - static void _getVars(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint* cVars, ILVarInfo** vars, bool* extendOthers) + private static void _getVars(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint* cVars, ILVarInfo** vars, bool* extendOthers) { var _this = GetThis(thisHandle); try @@ -1447,7 +1447,7 @@ static void _getVars(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRU } [UnmanagedCallersOnly] - static void _setVars(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint cVars, NativeVarInfo* vars) + private static void _setVars(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, uint cVars, NativeVarInfo* vars) { var _this = GetThis(thisHandle); try @@ -1461,7 +1461,7 @@ static void _setVars(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRU } [UnmanagedCallersOnly] - static void _reportRichMappings(IntPtr thisHandle, IntPtr* ppException, InlineTreeNode* inlineTreeNodes, uint numInlineTreeNodes, RichOffsetMapping* mappings, uint numMappings) + private static void _reportRichMappings(IntPtr thisHandle, IntPtr* ppException, InlineTreeNode* inlineTreeNodes, uint numInlineTreeNodes, RichOffsetMapping* mappings, uint numMappings) { var _this = GetThis(thisHandle); try @@ -1475,7 +1475,7 @@ static void _reportRichMappings(IntPtr thisHandle, IntPtr* ppException, InlineTr } [UnmanagedCallersOnly] - static void* _allocateArray(IntPtr thisHandle, IntPtr* ppException, UIntPtr cBytes) + private static void* _allocateArray(IntPtr thisHandle, IntPtr* ppException, UIntPtr cBytes) { var _this = GetThis(thisHandle); try @@ -1490,7 +1490,7 @@ static void _reportRichMappings(IntPtr thisHandle, IntPtr* ppException, InlineTr } [UnmanagedCallersOnly] - static void _freeArray(IntPtr thisHandle, IntPtr* ppException, void* array) + private static void _freeArray(IntPtr thisHandle, IntPtr* ppException, void* array) { var _this = GetThis(thisHandle); try @@ -1504,7 +1504,7 @@ static void _freeArray(IntPtr thisHandle, IntPtr* ppException, void* array) } [UnmanagedCallersOnly] - static CORINFO_ARG_LIST_STRUCT_* _getArgNext(IntPtr thisHandle, IntPtr* ppException, CORINFO_ARG_LIST_STRUCT_* args) + private static CORINFO_ARG_LIST_STRUCT_* _getArgNext(IntPtr thisHandle, IntPtr* ppException, CORINFO_ARG_LIST_STRUCT_* args) { var _this = GetThis(thisHandle); try @@ -1519,7 +1519,7 @@ static void _freeArray(IntPtr thisHandle, IntPtr* ppException, void* array) } [UnmanagedCallersOnly] - static CorInfoTypeWithMod _getArgType(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_STRUCT_* args, CORINFO_CLASS_STRUCT_** vcTypeRet) + private static CorInfoTypeWithMod _getArgType(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_STRUCT_* args, CORINFO_CLASS_STRUCT_** vcTypeRet) { var _this = GetThis(thisHandle); try @@ -1534,7 +1534,7 @@ static CorInfoTypeWithMod _getArgType(IntPtr thisHandle, IntPtr* ppException, CO } [UnmanagedCallersOnly] - static int _getExactClasses(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* baseType, int maxExactClasses, CORINFO_CLASS_STRUCT_** exactClsRet) + private static int _getExactClasses(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* baseType, int maxExactClasses, CORINFO_CLASS_STRUCT_** exactClsRet) { var _this = GetThis(thisHandle); try @@ -1549,7 +1549,7 @@ static int _getExactClasses(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLAS } [UnmanagedCallersOnly] - static CORINFO_CLASS_STRUCT_* _getArgClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_STRUCT_* args) + private static CORINFO_CLASS_STRUCT_* _getArgClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_STRUCT_* args) { var _this = GetThis(thisHandle); try @@ -1564,7 +1564,7 @@ static int _getExactClasses(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLAS } [UnmanagedCallersOnly] - static CorInfoHFAElemType _getHFAType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* hClass) + private static CorInfoHFAElemType _getHFAType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* hClass) { var _this = GetThis(thisHandle); try @@ -1579,7 +1579,7 @@ static CorInfoHFAElemType _getHFAType(IntPtr thisHandle, IntPtr* ppException, CO } [UnmanagedCallersOnly] - static HRESULT _GetErrorHRESULT(IntPtr thisHandle, IntPtr* ppException, _EXCEPTION_POINTERS* pExceptionPointers) + private static HRESULT _GetErrorHRESULT(IntPtr thisHandle, IntPtr* ppException, _EXCEPTION_POINTERS* pExceptionPointers) { var _this = GetThis(thisHandle); try @@ -1594,7 +1594,7 @@ static HRESULT _GetErrorHRESULT(IntPtr thisHandle, IntPtr* ppException, _EXCEPTI } [UnmanagedCallersOnly] - static uint _GetErrorMessage(IntPtr thisHandle, IntPtr* ppException, char* buffer, uint bufferLength) + private static uint _GetErrorMessage(IntPtr thisHandle, IntPtr* ppException, char* buffer, uint bufferLength) { var _this = GetThis(thisHandle); try @@ -1609,7 +1609,7 @@ static uint _GetErrorMessage(IntPtr thisHandle, IntPtr* ppException, char* buffe } [UnmanagedCallersOnly] - static int _FilterException(IntPtr thisHandle, IntPtr* ppException, _EXCEPTION_POINTERS* pExceptionPointers) + private static int _FilterException(IntPtr thisHandle, IntPtr* ppException, _EXCEPTION_POINTERS* pExceptionPointers) { var _this = GetThis(thisHandle); try @@ -1624,7 +1624,7 @@ static int _FilterException(IntPtr thisHandle, IntPtr* ppException, _EXCEPTION_P } [UnmanagedCallersOnly] - static void _ThrowExceptionForJitResult(IntPtr thisHandle, IntPtr* ppException, HRESULT result) + private static void _ThrowExceptionForJitResult(IntPtr thisHandle, IntPtr* ppException, HRESULT result) { var _this = GetThis(thisHandle); try @@ -1638,7 +1638,7 @@ static void _ThrowExceptionForJitResult(IntPtr thisHandle, IntPtr* ppException, } [UnmanagedCallersOnly] - static void _ThrowExceptionForHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_HELPER_DESC* throwHelper) + private static void _ThrowExceptionForHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_HELPER_DESC* throwHelper) { var _this = GetThis(thisHandle); try @@ -1652,7 +1652,7 @@ static void _ThrowExceptionForHelper(IntPtr thisHandle, IntPtr* ppException, COR } [UnmanagedCallersOnly] - static byte _runWithErrorTrap(IntPtr thisHandle, IntPtr* ppException, void* function, void* parameter) + private static byte _runWithErrorTrap(IntPtr thisHandle, IntPtr* ppException, void* function, void* parameter) { var _this = GetThis(thisHandle); try @@ -1667,7 +1667,7 @@ static byte _runWithErrorTrap(IntPtr thisHandle, IntPtr* ppException, void* func } [UnmanagedCallersOnly] - static byte _runWithSPMIErrorTrap(IntPtr thisHandle, IntPtr* ppException, void* function, void* parameter) + private static byte _runWithSPMIErrorTrap(IntPtr thisHandle, IntPtr* ppException, void* function, void* parameter) { var _this = GetThis(thisHandle); try @@ -1682,7 +1682,7 @@ static byte _runWithSPMIErrorTrap(IntPtr thisHandle, IntPtr* ppException, void* } [UnmanagedCallersOnly] - static void _getEEInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_EE_INFO* pEEInfoOut) + private static void _getEEInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_EE_INFO* pEEInfoOut) { var _this = GetThis(thisHandle); try @@ -1696,7 +1696,7 @@ static void _getEEInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_EE_INFO* } [UnmanagedCallersOnly] - static char* _getJitTimeLogFilename(IntPtr thisHandle, IntPtr* ppException) + private static char* _getJitTimeLogFilename(IntPtr thisHandle, IntPtr* ppException) { var _this = GetThis(thisHandle); try @@ -1711,7 +1711,7 @@ static void _getEEInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_EE_INFO* } [UnmanagedCallersOnly] - static mdToken _getMethodDefFromMethod(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* hMethod) + private static mdToken _getMethodDefFromMethod(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* hMethod) { var _this = GetThis(thisHandle); try @@ -1726,7 +1726,7 @@ static mdToken _getMethodDefFromMethod(IntPtr thisHandle, IntPtr* ppException, C } [UnmanagedCallersOnly] - static byte* _getMethodName(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, byte** moduleName) + private static byte* _getMethodName(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, byte** moduleName) { var _this = GetThis(thisHandle); try @@ -1741,7 +1741,7 @@ static mdToken _getMethodDefFromMethod(IntPtr thisHandle, IntPtr* ppException, C } [UnmanagedCallersOnly] - static byte* _getMethodNameFromMetadata(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, byte** className, byte** namespaceName, byte** enclosingClassName) + private static byte* _getMethodNameFromMetadata(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, byte** className, byte** namespaceName, byte** enclosingClassName) { var _this = GetThis(thisHandle); try @@ -1756,7 +1756,7 @@ static mdToken _getMethodDefFromMethod(IntPtr thisHandle, IntPtr* ppException, C } [UnmanagedCallersOnly] - static uint _getMethodHash(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn) + private static uint _getMethodHash(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn) { var _this = GetThis(thisHandle); try @@ -1771,7 +1771,7 @@ static uint _getMethodHash(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHO } [UnmanagedCallersOnly] - static UIntPtr _findNameOfToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* moduleHandle, mdToken token, byte* szFQName, UIntPtr FQNameCapacity) + private static UIntPtr _findNameOfToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* moduleHandle, mdToken token, byte* szFQName, UIntPtr FQNameCapacity) { var _this = GetThis(thisHandle); try @@ -1786,7 +1786,7 @@ static UIntPtr _findNameOfToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_ } [UnmanagedCallersOnly] - static byte _getSystemVAmd64PassStructInRegisterDescriptor(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* structHnd, SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* structPassInRegDescPtr) + private static byte _getSystemVAmd64PassStructInRegisterDescriptor(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* structHnd, SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* structPassInRegDescPtr) { var _this = GetThis(thisHandle); try @@ -1801,7 +1801,7 @@ static byte _getSystemVAmd64PassStructInRegisterDescriptor(IntPtr thisHandle, In } [UnmanagedCallersOnly] - static uint _getLoongArch64PassStructInRegisterFlags(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* structHnd) + private static uint _getLoongArch64PassStructInRegisterFlags(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* structHnd) { var _this = GetThis(thisHandle); try @@ -1816,7 +1816,7 @@ static uint _getLoongArch64PassStructInRegisterFlags(IntPtr thisHandle, IntPtr* } [UnmanagedCallersOnly] - static uint _getThreadTLSIndex(IntPtr thisHandle, IntPtr* ppException, void** ppIndirection) + private static uint _getThreadTLSIndex(IntPtr thisHandle, IntPtr* ppException, void** ppIndirection) { var _this = GetThis(thisHandle); try @@ -1831,7 +1831,7 @@ static uint _getThreadTLSIndex(IntPtr thisHandle, IntPtr* ppException, void** pp } [UnmanagedCallersOnly] - static void* _getInlinedCallFrameVptr(IntPtr thisHandle, IntPtr* ppException, void** ppIndirection) + private static void* _getInlinedCallFrameVptr(IntPtr thisHandle, IntPtr* ppException, void** ppIndirection) { var _this = GetThis(thisHandle); try @@ -1846,7 +1846,7 @@ static uint _getThreadTLSIndex(IntPtr thisHandle, IntPtr* ppException, void** pp } [UnmanagedCallersOnly] - static int* _getAddrOfCaptureThreadGlobal(IntPtr thisHandle, IntPtr* ppException, void** ppIndirection) + private static int* _getAddrOfCaptureThreadGlobal(IntPtr thisHandle, IntPtr* ppException, void** ppIndirection) { var _this = GetThis(thisHandle); try @@ -1861,7 +1861,7 @@ static uint _getThreadTLSIndex(IntPtr thisHandle, IntPtr* ppException, void** pp } [UnmanagedCallersOnly] - static void* _getHelperFtn(IntPtr thisHandle, IntPtr* ppException, CorInfoHelpFunc ftnNum, void** ppIndirection) + private static void* _getHelperFtn(IntPtr thisHandle, IntPtr* ppException, CorInfoHelpFunc ftnNum, void** ppIndirection) { var _this = GetThis(thisHandle); try @@ -1876,7 +1876,7 @@ static uint _getThreadTLSIndex(IntPtr thisHandle, IntPtr* ppException, void** pp } [UnmanagedCallersOnly] - static void _getFunctionEntryPoint(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, CORINFO_CONST_LOOKUP* pResult, CORINFO_ACCESS_FLAGS accessFlags) + private static void _getFunctionEntryPoint(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, CORINFO_CONST_LOOKUP* pResult, CORINFO_ACCESS_FLAGS accessFlags) { var _this = GetThis(thisHandle); try @@ -1890,7 +1890,7 @@ static void _getFunctionEntryPoint(IntPtr thisHandle, IntPtr* ppException, CORIN } [UnmanagedCallersOnly] - static void _getFunctionFixedEntryPoint(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, byte isUnsafeFunctionPointer, CORINFO_CONST_LOOKUP* pResult) + private static void _getFunctionFixedEntryPoint(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, byte isUnsafeFunctionPointer, CORINFO_CONST_LOOKUP* pResult) { var _this = GetThis(thisHandle); try @@ -1904,7 +1904,7 @@ static void _getFunctionFixedEntryPoint(IntPtr thisHandle, IntPtr* ppException, } [UnmanagedCallersOnly] - static void* _getMethodSync(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, void** ppIndirection) + private static void* _getMethodSync(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, void** ppIndirection) { var _this = GetThis(thisHandle); try @@ -1919,7 +1919,7 @@ static void _getFunctionFixedEntryPoint(IntPtr thisHandle, IntPtr* ppException, } [UnmanagedCallersOnly] - static CorInfoHelpFunc _getLazyStringLiteralHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* handle) + private static CorInfoHelpFunc _getLazyStringLiteralHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* handle) { var _this = GetThis(thisHandle); try @@ -1934,7 +1934,7 @@ static CorInfoHelpFunc _getLazyStringLiteralHelper(IntPtr thisHandle, IntPtr* pp } [UnmanagedCallersOnly] - static CORINFO_MODULE_STRUCT_* _embedModuleHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* handle, void** ppIndirection) + private static CORINFO_MODULE_STRUCT_* _embedModuleHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* handle, void** ppIndirection) { var _this = GetThis(thisHandle); try @@ -1949,7 +1949,7 @@ static CorInfoHelpFunc _getLazyStringLiteralHelper(IntPtr thisHandle, IntPtr* pp } [UnmanagedCallersOnly] - static CORINFO_CLASS_STRUCT_* _embedClassHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* handle, void** ppIndirection) + private static CORINFO_CLASS_STRUCT_* _embedClassHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* handle, void** ppIndirection) { var _this = GetThis(thisHandle); try @@ -1964,7 +1964,7 @@ static CorInfoHelpFunc _getLazyStringLiteralHelper(IntPtr thisHandle, IntPtr* pp } [UnmanagedCallersOnly] - static CORINFO_METHOD_STRUCT_* _embedMethodHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* handle, void** ppIndirection) + private static CORINFO_METHOD_STRUCT_* _embedMethodHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* handle, void** ppIndirection) { var _this = GetThis(thisHandle); try @@ -1979,7 +1979,7 @@ static CorInfoHelpFunc _getLazyStringLiteralHelper(IntPtr thisHandle, IntPtr* pp } [UnmanagedCallersOnly] - static CORINFO_FIELD_STRUCT_* _embedFieldHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* handle, void** ppIndirection) + private static CORINFO_FIELD_STRUCT_* _embedFieldHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* handle, void** ppIndirection) { var _this = GetThis(thisHandle); try @@ -1994,7 +1994,7 @@ static CorInfoHelpFunc _getLazyStringLiteralHelper(IntPtr thisHandle, IntPtr* pp } [UnmanagedCallersOnly] - static void _embedGenericHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, byte fEmbedParent, CORINFO_GENERICHANDLE_RESULT* pResult) + private static void _embedGenericHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, byte fEmbedParent, CORINFO_GENERICHANDLE_RESULT* pResult) { var _this = GetThis(thisHandle); try @@ -2008,7 +2008,7 @@ static void _embedGenericHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_ } [UnmanagedCallersOnly] - static void _getLocationOfThisType(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* context, CORINFO_LOOKUP_KIND* pLookupKind) + private static void _getLocationOfThisType(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* context, CORINFO_LOOKUP_KIND* pLookupKind) { var _this = GetThis(thisHandle); try @@ -2022,7 +2022,7 @@ static void _getLocationOfThisType(IntPtr thisHandle, IntPtr* ppException, CORIN } [UnmanagedCallersOnly] - static void _getAddressOfPInvokeTarget(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, CORINFO_CONST_LOOKUP* pLookup) + private static void _getAddressOfPInvokeTarget(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, CORINFO_CONST_LOOKUP* pLookup) { var _this = GetThis(thisHandle); try @@ -2036,7 +2036,7 @@ static void _getAddressOfPInvokeTarget(IntPtr thisHandle, IntPtr* ppException, C } [UnmanagedCallersOnly] - static void* _GetCookieForPInvokeCalliSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* szMetaSig, void** ppIndirection) + private static void* _GetCookieForPInvokeCalliSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* szMetaSig, void** ppIndirection) { var _this = GetThis(thisHandle); try @@ -2051,7 +2051,7 @@ static void _getAddressOfPInvokeTarget(IntPtr thisHandle, IntPtr* ppException, C } [UnmanagedCallersOnly] - static byte _canGetCookieForPInvokeCalliSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* szMetaSig) + private static byte _canGetCookieForPInvokeCalliSig(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* szMetaSig) { var _this = GetThis(thisHandle); try @@ -2066,7 +2066,7 @@ static byte _canGetCookieForPInvokeCalliSig(IntPtr thisHandle, IntPtr* ppExcepti } [UnmanagedCallersOnly] - static CORINFO_JUST_MY_CODE_HANDLE_* _getJustMyCodeHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, CORINFO_JUST_MY_CODE_HANDLE_** ppIndirection) + private static CORINFO_JUST_MY_CODE_HANDLE_* _getJustMyCodeHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, CORINFO_JUST_MY_CODE_HANDLE_** ppIndirection) { var _this = GetThis(thisHandle); try @@ -2081,7 +2081,7 @@ static byte _canGetCookieForPInvokeCalliSig(IntPtr thisHandle, IntPtr* ppExcepti } [UnmanagedCallersOnly] - static void _GetProfilingHandle(IntPtr thisHandle, IntPtr* ppException, bool* pbHookFunction, void** pProfilerHandle, bool* pbIndirectedHandles) + private static void _GetProfilingHandle(IntPtr thisHandle, IntPtr* ppException, bool* pbHookFunction, void** pProfilerHandle, bool* pbIndirectedHandles) { var _this = GetThis(thisHandle); try @@ -2095,7 +2095,7 @@ static void _GetProfilingHandle(IntPtr thisHandle, IntPtr* ppException, bool* pb } [UnmanagedCallersOnly] - static void _getCallInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_CALLINFO_FLAGS flags, CORINFO_CALL_INFO* pResult) + private static void _getCallInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_CALLINFO_FLAGS flags, CORINFO_CALL_INFO* pResult) { var _this = GetThis(thisHandle); try @@ -2109,7 +2109,7 @@ static void _getCallInfo(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVE } [UnmanagedCallersOnly] - static byte _canAccessFamily(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* hCaller, CORINFO_CLASS_STRUCT_* hInstanceType) + private static byte _canAccessFamily(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* hCaller, CORINFO_CLASS_STRUCT_* hInstanceType) { var _this = GetThis(thisHandle); try @@ -2124,7 +2124,7 @@ static byte _canAccessFamily(IntPtr thisHandle, IntPtr* ppException, CORINFO_MET } [UnmanagedCallersOnly] - static byte _isRIDClassDomainID(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + private static byte _isRIDClassDomainID(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { var _this = GetThis(thisHandle); try @@ -2139,7 +2139,7 @@ static byte _isRIDClassDomainID(IntPtr thisHandle, IntPtr* ppException, CORINFO_ } [UnmanagedCallersOnly] - static uint _getClassDomainID(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, void** ppIndirection) + private static uint _getClassDomainID(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, void** ppIndirection) { var _this = GetThis(thisHandle); try @@ -2154,7 +2154,7 @@ static uint _getClassDomainID(IntPtr thisHandle, IntPtr* ppException, CORINFO_CL } [UnmanagedCallersOnly] - static void* _getFieldAddress(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, void** ppIndirection) + private static void* _getFieldAddress(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, void** ppIndirection) { var _this = GetThis(thisHandle); try @@ -2169,7 +2169,7 @@ static uint _getClassDomainID(IntPtr thisHandle, IntPtr* ppException, CORINFO_CL } [UnmanagedCallersOnly] - static CORINFO_CLASS_STRUCT_* _getStaticFieldCurrentClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, byte* pIsSpeculative) + private static CORINFO_CLASS_STRUCT_* _getStaticFieldCurrentClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, byte* pIsSpeculative) { var _this = GetThis(thisHandle); try @@ -2184,7 +2184,7 @@ static uint _getClassDomainID(IntPtr thisHandle, IntPtr* ppException, CORINFO_CL } [UnmanagedCallersOnly] - static IntPtr _getVarArgsHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* pSig, void** ppIndirection) + private static IntPtr _getVarArgsHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* pSig, void** ppIndirection) { var _this = GetThis(thisHandle); try @@ -2199,7 +2199,7 @@ static IntPtr _getVarArgsHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_ } [UnmanagedCallersOnly] - static byte _canGetVarArgsHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* pSig) + private static byte _canGetVarArgsHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO_SIG_INFO* pSig) { var _this = GetThis(thisHandle); try @@ -2214,7 +2214,7 @@ static byte _canGetVarArgsHandle(IntPtr thisHandle, IntPtr* ppException, CORINFO } [UnmanagedCallersOnly] - static InfoAccessType _constructStringLiteral(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, mdToken metaTok, void** ppValue) + private static InfoAccessType _constructStringLiteral(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* module, mdToken metaTok, void** ppValue) { var _this = GetThis(thisHandle); try @@ -2229,7 +2229,7 @@ static InfoAccessType _constructStringLiteral(IntPtr thisHandle, IntPtr* ppExcep } [UnmanagedCallersOnly] - static InfoAccessType _emptyStringLiteral(IntPtr thisHandle, IntPtr* ppException, void** ppValue) + private static InfoAccessType _emptyStringLiteral(IntPtr thisHandle, IntPtr* ppException, void** ppValue) { var _this = GetThis(thisHandle); try @@ -2244,7 +2244,7 @@ static InfoAccessType _emptyStringLiteral(IntPtr thisHandle, IntPtr* ppException } [UnmanagedCallersOnly] - static uint _getFieldThreadLocalStoreID(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, void** ppIndirection) + private static uint _getFieldThreadLocalStoreID(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, void** ppIndirection) { var _this = GetThis(thisHandle); try @@ -2259,7 +2259,7 @@ static uint _getFieldThreadLocalStoreID(IntPtr thisHandle, IntPtr* ppException, } [UnmanagedCallersOnly] - static void _addActiveDependency(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* moduleFrom, CORINFO_MODULE_STRUCT_* moduleTo) + private static void _addActiveDependency(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* moduleFrom, CORINFO_MODULE_STRUCT_* moduleTo) { var _this = GetThis(thisHandle); try @@ -2273,7 +2273,7 @@ static void _addActiveDependency(IntPtr thisHandle, IntPtr* ppException, CORINFO } [UnmanagedCallersOnly] - static CORINFO_METHOD_STRUCT_* _GetDelegateCtor(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* methHnd, CORINFO_CLASS_STRUCT_* clsHnd, CORINFO_METHOD_STRUCT_* targetMethodHnd, DelegateCtorArgs* pCtorData) + private static CORINFO_METHOD_STRUCT_* _GetDelegateCtor(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* methHnd, CORINFO_CLASS_STRUCT_* clsHnd, CORINFO_METHOD_STRUCT_* targetMethodHnd, DelegateCtorArgs* pCtorData) { var _this = GetThis(thisHandle); try @@ -2288,7 +2288,7 @@ static void _addActiveDependency(IntPtr thisHandle, IntPtr* ppException, CORINFO } [UnmanagedCallersOnly] - static void _MethodCompileComplete(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* methHnd) + private static void _MethodCompileComplete(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* methHnd) { var _this = GetThis(thisHandle); try @@ -2302,7 +2302,7 @@ static void _MethodCompileComplete(IntPtr thisHandle, IntPtr* ppException, CORIN } [UnmanagedCallersOnly] - static byte _getTailCallHelpers(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* callToken, CORINFO_SIG_INFO* sig, CORINFO_GET_TAILCALL_HELPERS_FLAGS flags, CORINFO_TAILCALL_HELPERS* pResult) + private static byte _getTailCallHelpers(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* callToken, CORINFO_SIG_INFO* sig, CORINFO_GET_TAILCALL_HELPERS_FLAGS flags, CORINFO_TAILCALL_HELPERS* pResult) { var _this = GetThis(thisHandle); try @@ -2317,7 +2317,7 @@ static byte _getTailCallHelpers(IntPtr thisHandle, IntPtr* ppException, CORINFO_ } [UnmanagedCallersOnly] - static byte _convertPInvokeCalliToCall(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, byte mustConvert) + private static byte _convertPInvokeCalliToCall(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, byte mustConvert) { var _this = GetThis(thisHandle); try @@ -2332,7 +2332,7 @@ static byte _convertPInvokeCalliToCall(IntPtr thisHandle, IntPtr* ppException, C } [UnmanagedCallersOnly] - static byte _notifyInstructionSetUsage(IntPtr thisHandle, IntPtr* ppException, InstructionSet instructionSet, byte supportEnabled) + private static byte _notifyInstructionSetUsage(IntPtr thisHandle, IntPtr* ppException, InstructionSet instructionSet, byte supportEnabled) { var _this = GetThis(thisHandle); try @@ -2347,7 +2347,7 @@ static byte _notifyInstructionSetUsage(IntPtr thisHandle, IntPtr* ppException, I } [UnmanagedCallersOnly] - static void _updateEntryPointForTailCall(IntPtr thisHandle, IntPtr* ppException, CORINFO_CONST_LOOKUP* entryPoint) + private static void _updateEntryPointForTailCall(IntPtr thisHandle, IntPtr* ppException, CORINFO_CONST_LOOKUP* entryPoint) { var _this = GetThis(thisHandle); try @@ -2361,7 +2361,7 @@ static void _updateEntryPointForTailCall(IntPtr thisHandle, IntPtr* ppException, } [UnmanagedCallersOnly] - static void _allocMem(IntPtr thisHandle, IntPtr* ppException, AllocMemArgs* pArgs) + private static void _allocMem(IntPtr thisHandle, IntPtr* ppException, AllocMemArgs* pArgs) { var _this = GetThis(thisHandle); try @@ -2375,7 +2375,7 @@ static void _allocMem(IntPtr thisHandle, IntPtr* ppException, AllocMemArgs* pArg } [UnmanagedCallersOnly] - static void _reserveUnwindInfo(IntPtr thisHandle, IntPtr* ppException, byte isFunclet, byte isColdCode, uint unwindSize) + private static void _reserveUnwindInfo(IntPtr thisHandle, IntPtr* ppException, byte isFunclet, byte isColdCode, uint unwindSize) { var _this = GetThis(thisHandle); try @@ -2389,7 +2389,7 @@ static void _reserveUnwindInfo(IntPtr thisHandle, IntPtr* ppException, byte isFu } [UnmanagedCallersOnly] - static void _allocUnwindInfo(IntPtr thisHandle, IntPtr* ppException, byte* pHotCode, byte* pColdCode, uint startOffset, uint endOffset, uint unwindSize, byte* pUnwindBlock, CorJitFuncKind funcKind) + private static void _allocUnwindInfo(IntPtr thisHandle, IntPtr* ppException, byte* pHotCode, byte* pColdCode, uint startOffset, uint endOffset, uint unwindSize, byte* pUnwindBlock, CorJitFuncKind funcKind) { var _this = GetThis(thisHandle); try @@ -2403,7 +2403,7 @@ static void _allocUnwindInfo(IntPtr thisHandle, IntPtr* ppException, byte* pHotC } [UnmanagedCallersOnly] - static void* _allocGCInfo(IntPtr thisHandle, IntPtr* ppException, UIntPtr size) + private static void* _allocGCInfo(IntPtr thisHandle, IntPtr* ppException, UIntPtr size) { var _this = GetThis(thisHandle); try @@ -2418,7 +2418,7 @@ static void _allocUnwindInfo(IntPtr thisHandle, IntPtr* ppException, byte* pHotC } [UnmanagedCallersOnly] - static void _setEHcount(IntPtr thisHandle, IntPtr* ppException, uint cEH) + private static void _setEHcount(IntPtr thisHandle, IntPtr* ppException, uint cEH) { var _this = GetThis(thisHandle); try @@ -2432,7 +2432,7 @@ static void _setEHcount(IntPtr thisHandle, IntPtr* ppException, uint cEH) } [UnmanagedCallersOnly] - static void _setEHinfo(IntPtr thisHandle, IntPtr* ppException, uint EHnumber, CORINFO_EH_CLAUSE* clause) + private static void _setEHinfo(IntPtr thisHandle, IntPtr* ppException, uint EHnumber, CORINFO_EH_CLAUSE* clause) { var _this = GetThis(thisHandle); try @@ -2446,7 +2446,7 @@ static void _setEHinfo(IntPtr thisHandle, IntPtr* ppException, uint EHnumber, CO } [UnmanagedCallersOnly] - static byte _logMsg(IntPtr thisHandle, IntPtr* ppException, uint level, byte* fmt, IntPtr args) + private static byte _logMsg(IntPtr thisHandle, IntPtr* ppException, uint level, byte* fmt, IntPtr args) { var _this = GetThis(thisHandle); try @@ -2461,7 +2461,7 @@ static byte _logMsg(IntPtr thisHandle, IntPtr* ppException, uint level, byte* fm } [UnmanagedCallersOnly] - static int _doAssert(IntPtr thisHandle, IntPtr* ppException, byte* szFile, int iLine, byte* szExpr) + private static int _doAssert(IntPtr thisHandle, IntPtr* ppException, byte* szFile, int iLine, byte* szExpr) { var _this = GetThis(thisHandle); try @@ -2476,7 +2476,7 @@ static int _doAssert(IntPtr thisHandle, IntPtr* ppException, byte* szFile, int i } [UnmanagedCallersOnly] - static void _reportFatalError(IntPtr thisHandle, IntPtr* ppException, CorJitResult result) + private static void _reportFatalError(IntPtr thisHandle, IntPtr* ppException, CorJitResult result) { var _this = GetThis(thisHandle); try @@ -2490,7 +2490,7 @@ static void _reportFatalError(IntPtr thisHandle, IntPtr* ppException, CorJitResu } [UnmanagedCallersOnly] - static HRESULT _getPgoInstrumentationResults(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftnHnd, PgoInstrumentationSchema** pSchema, uint* pCountSchemaItems, byte** pInstrumentationData, PgoSource* pgoSource) + private static HRESULT _getPgoInstrumentationResults(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftnHnd, PgoInstrumentationSchema** pSchema, uint* pCountSchemaItems, byte** pInstrumentationData, PgoSource* pgoSource) { var _this = GetThis(thisHandle); try @@ -2505,7 +2505,7 @@ static HRESULT _getPgoInstrumentationResults(IntPtr thisHandle, IntPtr* ppExcept } [UnmanagedCallersOnly] - static HRESULT _allocPgoInstrumentationBySchema(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftnHnd, PgoInstrumentationSchema* pSchema, uint countSchemaItems, byte** pInstrumentationData) + private static HRESULT _allocPgoInstrumentationBySchema(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftnHnd, PgoInstrumentationSchema* pSchema, uint countSchemaItems, byte** pInstrumentationData) { var _this = GetThis(thisHandle); try @@ -2520,7 +2520,7 @@ static HRESULT _allocPgoInstrumentationBySchema(IntPtr thisHandle, IntPtr* ppExc } [UnmanagedCallersOnly] - static void _recordCallSite(IntPtr thisHandle, IntPtr* ppException, uint instrOffset, CORINFO_SIG_INFO* callSig, CORINFO_METHOD_STRUCT_* methodHandle) + private static void _recordCallSite(IntPtr thisHandle, IntPtr* ppException, uint instrOffset, CORINFO_SIG_INFO* callSig, CORINFO_METHOD_STRUCT_* methodHandle) { var _this = GetThis(thisHandle); try @@ -2534,7 +2534,7 @@ static void _recordCallSite(IntPtr thisHandle, IntPtr* ppException, uint instrOf } [UnmanagedCallersOnly] - static void _recordRelocation(IntPtr thisHandle, IntPtr* ppException, void* location, void* locationRW, void* target, ushort fRelocType, ushort slotNum, int addlDelta) + private static void _recordRelocation(IntPtr thisHandle, IntPtr* ppException, void* location, void* locationRW, void* target, ushort fRelocType, ushort slotNum, int addlDelta) { var _this = GetThis(thisHandle); try @@ -2548,7 +2548,7 @@ static void _recordRelocation(IntPtr thisHandle, IntPtr* ppException, void* loca } [UnmanagedCallersOnly] - static ushort _getRelocTypeHint(IntPtr thisHandle, IntPtr* ppException, void* target) + private static ushort _getRelocTypeHint(IntPtr thisHandle, IntPtr* ppException, void* target) { var _this = GetThis(thisHandle); try @@ -2563,7 +2563,7 @@ static ushort _getRelocTypeHint(IntPtr thisHandle, IntPtr* ppException, void* ta } [UnmanagedCallersOnly] - static uint _getExpectedTargetArchitecture(IntPtr thisHandle, IntPtr* ppException) + private static uint _getExpectedTargetArchitecture(IntPtr thisHandle, IntPtr* ppException) { var _this = GetThis(thisHandle); try @@ -2578,7 +2578,7 @@ static uint _getExpectedTargetArchitecture(IntPtr thisHandle, IntPtr* ppExceptio } [UnmanagedCallersOnly] - static uint _getJitFlags(IntPtr thisHandle, IntPtr* ppException, CORJIT_FLAGS* flags, uint sizeInBytes) + private static uint _getJitFlags(IntPtr thisHandle, IntPtr* ppException, CORJIT_FLAGS* flags, uint sizeInBytes) { var _this = GetThis(thisHandle); try @@ -2592,8 +2592,7 @@ static uint _getJitFlags(IntPtr thisHandle, IntPtr* ppException, CORJIT_FLAGS* f } } - - static IntPtr GetUnmanagedCallbacks() + private static IntPtr GetUnmanagedCallbacks() { void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 175); @@ -2777,4 +2776,3 @@ static IntPtr GetUnmanagedCallbacks() } } } - diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoHelpFunc.cs b/src/coreclr/tools/Common/JitInterface/CorInfoHelpFunc.cs index b0a53c8232e56..c6774127307e0 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoHelpFunc.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoHelpFunc.cs @@ -1,10 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; -using System.Text; - namespace Internal.JitInterface { // CorInfoHelpFunc defines the set of helpers (accessed via the ICorDynamicInfo::getHelperFtn()) @@ -54,9 +50,9 @@ which is the right helper to use to allocate an object of a given type. */ CORINFO_HELP_NEWSFAST, // allocator for small, non-finalizer, non-array object CORINFO_HELP_NEWSFAST_FINALIZE, // allocator for small, finalizable, non-array object CORINFO_HELP_NEWSFAST_ALIGN8, // allocator for small, non-finalizer, non-array object, 8 byte aligned - CORINFO_HELP_NEWSFAST_ALIGN8_VC,// allocator for small, value class, 8 byte aligned + CORINFO_HELP_NEWSFAST_ALIGN8_VC, // allocator for small, value class, 8 byte aligned CORINFO_HELP_NEWSFAST_ALIGN8_FINALIZE, // allocator for small, finalizable, non-array object, 8 byte aligned - CORINFO_HELP_NEW_MDARR,// multi-dim array helper (with or without lower bounds - dimensions passed in as unmanaged array) + CORINFO_HELP_NEW_MDARR, // multi-dim array helper (with or without lower bounds - dimensions passed in as unmanaged array) CORINFO_HELP_NEWARR_1_DIRECT, // helper for any one dimensional array creation CORINFO_HELP_NEWARR_1_OBJ, // optimized 1-D object arrays CORINFO_HELP_NEWARR_1_VC, // optimized 1-D value class arrays @@ -108,7 +104,7 @@ which is the right helper to use to allocate an object of a given type. */ CORINFO_HELP_VERIFICATION, // Throw a VerificationException CORINFO_HELP_FAIL_FAST, // Kill the process avoiding any exceptions or stack and data dependencies (use for GuardStack unsafe buffer checks) - CORINFO_HELP_METHOD_ACCESS_EXCEPTION,//Throw an access exception due to a failed member/class access check. + CORINFO_HELP_METHOD_ACCESS_EXCEPTION, //Throw an access exception due to a failed member/class access check. CORINFO_HELP_FIELD_ACCESS_EXCEPTION, CORINFO_HELP_CLASS_ACCESS_EXCEPTION, @@ -217,9 +213,9 @@ which is the right helper to use to allocate an object of a given type. */ CORINFO_HELP_MEMCPY, // Copy block of memory CORINFO_HELP_RUNTIMEHANDLE_METHOD, // determine a type/field/method handle at run-time - CORINFO_HELP_RUNTIMEHANDLE_METHOD_LOG,// determine a type/field/method handle at run-time, with IBC logging + CORINFO_HELP_RUNTIMEHANDLE_METHOD_LOG, // determine a type/field/method handle at run-time, with IBC logging CORINFO_HELP_RUNTIMEHANDLE_CLASS, // determine a type/field/method handle at run-time - CORINFO_HELP_RUNTIMEHANDLE_CLASS_LOG,// determine a type/field/method handle at run-time, with IBC logging + CORINFO_HELP_RUNTIMEHANDLE_CLASS_LOG, // determine a type/field/method handle at run-time, with IBC logging CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE, // Convert from a TypeHandle (native structure pointer) to RuntimeType at run-time CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL, // Convert from a TypeHandle (native structure pointer) to RuntimeType at run-time, the type may be null @@ -243,8 +239,8 @@ which is the right helper to use to allocate an object of a given type. */ CORINFO_HELP_READYTORUN_DELEGATE_CTOR, CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE, - CORINFO_HELP_EE_PERSONALITY_ROUTINE,// Not real JIT helper. Used in native images. - CORINFO_HELP_EE_PERSONALITY_ROUTINE_FILTER_FUNCLET,// Not real JIT helper. Used in native images to detect filter funclets. + CORINFO_HELP_EE_PERSONALITY_ROUTINE, // Not real JIT helper. Used in native images. + CORINFO_HELP_EE_PERSONALITY_ROUTINE_FILTER_FUNCLET, // Not real JIT helper. Used in native images to detect filter funclets. // ASSIGN_REF_EAX - CHECKED_ASSIGN_REF_EBP: NOGC_WRITE_BARRIERS JIT helper calls // diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index c1f59c124b676..c5f6ba4113935 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -3,11 +3,9 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; using System.Diagnostics; using System.IO; using System.Text; -using System.Reflection.Metadata; using System.Runtime.CompilerServices; using System.Runtime.ExceptionServices; using System.Runtime.InteropServices; @@ -25,7 +23,6 @@ using ILCompiler; using ILCompiler.DependencyAnalysis; -using Internal.IL.Stubs; #if READYTORUN using System.Reflection.Metadata.Ecma335; @@ -34,7 +31,7 @@ namespace Internal.JitInterface { - enum CompilationResult + internal enum CompilationResult { CompilationComplete, CompilationRetryRequested @@ -76,18 +73,19 @@ private struct PgoInstrumentationResults public byte* pInstrumentationData; public HRESULT hr; } - Dictionary _pgoResults = new Dictionary(); + + private Dictionary _pgoResults = new Dictionary(); [DllImport(JitLibrary)] - private extern static IntPtr jitStartup(IntPtr host); + private static extern IntPtr jitStartup(IntPtr host); private static class JitPointerAccessor { [DllImport(JitLibrary)] - private extern static IntPtr getJit(); + private static extern IntPtr getJit(); [DllImport(JitSupportLibrary)] - private extern static CorJitResult JitProcessShutdownWork(IntPtr jit); + private static extern CorJitResult JitProcessShutdownWork(IntPtr jit); static JitPointerAccessor() { @@ -121,13 +119,13 @@ public LikelyClassMethodRecord(IntPtr handle, uint likelihood) } [DllImport(JitLibrary)] - private extern static uint getLikelyClasses(LikelyClassMethodRecord* pLikelyClasses, uint maxLikelyClasses, PgoInstrumentationSchema* schema, uint countSchemaItems, byte*pInstrumentationData, int ilOffset); + private static extern uint getLikelyClasses(LikelyClassMethodRecord* pLikelyClasses, uint maxLikelyClasses, PgoInstrumentationSchema* schema, uint countSchemaItems, byte*pInstrumentationData, int ilOffset); [DllImport(JitLibrary)] - private extern static uint getLikelyMethods(LikelyClassMethodRecord* pLikelyMethods, uint maxLikelyMethods, PgoInstrumentationSchema* schema, uint countSchemaItems, byte*pInstrumentationData, int ilOffset); + private static extern uint getLikelyMethods(LikelyClassMethodRecord* pLikelyMethods, uint maxLikelyMethods, PgoInstrumentationSchema* schema, uint countSchemaItems, byte*pInstrumentationData, int ilOffset); [DllImport(JitSupportLibrary)] - private extern static IntPtr GetJitHost(IntPtr configProvider); + private static extern IntPtr GetJitHost(IntPtr configProvider); // // Per-method initialization and state @@ -140,18 +138,18 @@ private static CorInfoImpl GetThis(IntPtr thisHandle) } [DllImport(JitSupportLibrary)] - private extern static CorJitResult JitCompileMethod(out IntPtr exception, + private static extern CorJitResult JitCompileMethod(out IntPtr exception, IntPtr jit, IntPtr thisHandle, IntPtr callbacks, ref CORINFO_METHOD_INFO info, uint flags, out IntPtr nativeEntry, out uint codeSize); [DllImport(JitSupportLibrary)] - private extern static uint GetMaxIntrinsicSIMDVectorLength(IntPtr jit, CORJIT_FLAGS* flags); + private static extern uint GetMaxIntrinsicSIMDVectorLength(IntPtr jit, CORJIT_FLAGS* flags); [DllImport(JitSupportLibrary)] - private extern static IntPtr AllocException([MarshalAs(UnmanagedType.LPWStr)]string message, int messageLength); + private static extern IntPtr AllocException([MarshalAs(UnmanagedType.LPWStr)]string message, int messageLength); [DllImport(JitSupportLibrary)] - private extern static void JitSetOs(IntPtr jit, CORINFO_OS os); + private static extern void JitSetOs(IntPtr jit, CORINFO_OS os); private IntPtr AllocException(Exception ex) { @@ -159,19 +157,16 @@ private IntPtr AllocException(Exception ex) string exString = ex.ToString(); IntPtr nativeException = AllocException(exString, exString.Length); - if (_nativeExceptions == null) - { - _nativeExceptions = new List(); - } + _nativeExceptions ??= new List(); _nativeExceptions.Add(nativeException); return nativeException; } [DllImport(JitSupportLibrary)] - private extern static void FreeException(IntPtr obj); + private static extern void FreeException(IntPtr obj); [DllImport(JitSupportLibrary)] - private extern static char* GetExceptionMessage(IntPtr obj); + private static extern char* GetExceptionMessage(IntPtr obj); public static void Startup(CORINFO_OS os) { @@ -312,7 +307,7 @@ IntPtr LocalObjectToHandle(object input) if (newData != null) { - PgoSchemaElem likelyClassElem = new PgoSchemaElem(); + PgoSchemaElem likelyClassElem = default(PgoSchemaElem); likelyClassElem.InstrumentationKind = isType ? PgoInstrumentationKind.GetLikelyClass : PgoInstrumentationKind.GetLikelyMethod; likelyClassElem.ILOffset = nativeSchema[index].ILOffset; likelyClassElem.Count = 1; @@ -469,11 +464,13 @@ private void PublishCode() } } +#pragma warning disable SA1001, SA1113, SA1115 // Comma should be on the same line as previous parameter _methodCodeNode.SetCode(objectData #if !SUPPORT_JIT && !READYTORUN , isFoldable: (_compilation._compilationOptions & RyuJitCompilationOptions.MethodBodyFolding) != 0 #endif ); +#pragma warning restore SA1001, SA1113, SA1115 // Comma should be on the same line as previous parameter _methodCodeNode.InitializeFrameInfos(_frameInfos); _methodCodeNode.InitializeDebugEHClauseInfos(debugEHClauseInfos); @@ -586,9 +583,9 @@ private int PointerSize } } - private Dictionary _pins = new Dictionary(); + private Dictionary _pins = new Dictionary(); - private IntPtr GetPin(Object obj) + private IntPtr GetPin(object obj) { GCHandle handle; if (!_pins.TryGetValue(obj, out handle)) @@ -622,8 +619,8 @@ private void CompileMethodCleanup() _roData = null; _roDataBlob = null; - _codeRelocs = new ArrayBuilder(); - _roDataRelocs = new ArrayBuilder(); + _codeRelocs = default(ArrayBuilder); + _roDataRelocs = default(ArrayBuilder); _numFrameInfos = 0; _usedFrameInfos = 0; @@ -656,8 +653,8 @@ private void CompileMethodCleanup() _pgoResults.Clear(); } - private Dictionary _objectToHandle = new Dictionary(); - private List _handleToObject = new List(); + private Dictionary _objectToHandle = new Dictionary(); + private List _handleToObject = new List(); private const int handleMultiplier = 8; private const int handleBase = 0x420000; @@ -666,7 +663,7 @@ private void CompileMethodCleanup() private static readonly IntPtr s_handleHighBitSet = (sizeof(IntPtr) == 4) ? new IntPtr(0x40000000) : new IntPtr(0x4000000000000000); #endif - private IntPtr ObjectToHandle(Object obj) + private IntPtr ObjectToHandle(object obj) { // SuperPMI relies on the handle returned from this function being stable for the lifetime of the crossgen2 process // If handle deletion is implemented, please update SuperPMI @@ -683,7 +680,7 @@ private IntPtr ObjectToHandle(Object obj) return handle; } - private Object HandleToObject(IntPtr handle) + private object HandleToObject(IntPtr handle) { #if DEBUG handle = new IntPtr(~(long)s_handleHighBitSet & (long) handle); @@ -693,9 +690,9 @@ private Object HandleToObject(IntPtr handle) } private MethodDesc HandleToObject(CORINFO_METHOD_STRUCT_* method) => (MethodDesc)HandleToObject((IntPtr)method); - private CORINFO_METHOD_STRUCT_* ObjectToHandle(MethodDesc method) => (CORINFO_METHOD_STRUCT_*)ObjectToHandle((Object)method); + private CORINFO_METHOD_STRUCT_* ObjectToHandle(MethodDesc method) => (CORINFO_METHOD_STRUCT_*)ObjectToHandle((object)method); private TypeDesc HandleToObject(CORINFO_CLASS_STRUCT_* type) => (TypeDesc)HandleToObject((IntPtr)type); - private CORINFO_CLASS_STRUCT_* ObjectToHandle(TypeDesc type) => (CORINFO_CLASS_STRUCT_*)ObjectToHandle((Object)type); + private CORINFO_CLASS_STRUCT_* ObjectToHandle(TypeDesc type) => (CORINFO_CLASS_STRUCT_*)ObjectToHandle((object)type); private FieldDesc HandleToObject(CORINFO_FIELD_STRUCT_* field) => (FieldDesc)HandleToObject((IntPtr)field); private CORINFO_FIELD_STRUCT_* ObjectToHandle(FieldDesc field) => (CORINFO_FIELD_STRUCT_*)ObjectToHandle((object)field); private MethodILScope HandleToObject(CORINFO_MODULE_STRUCT_* module) => (MethodIL)HandleToObject((IntPtr)module); @@ -740,14 +737,11 @@ private bool Get_CORINFO_METHOD_INFO(MethodDesc method, MethodIL methodIL, CORIN return true; } - private Dictionary _instantiationToJitVisibleInstantiation = null; + private Dictionary _instantiationToJitVisibleInstantiation; private CORINFO_CLASS_STRUCT_** GetJitInstantiation(Instantiation inst) { IntPtr [] jitVisibleInstantiation; - if (_instantiationToJitVisibleInstantiation == null) - { - _instantiationToJitVisibleInstantiation = new Dictionary(); - } + _instantiationToJitVisibleInstantiation ??= new Dictionary(); if (!_instantiationToJitVisibleInstantiation.TryGetValue(inst, out jitVisibleInstantiation)) { @@ -1084,7 +1078,9 @@ private uint getMethodAttribsInternal(MethodDesc method) return (uint)result; } +#pragma warning disable CA1822 // Mark members as static private void setMethodAttribs(CORINFO_METHOD_STRUCT_* ftn, CorInfoMethodRuntimeFlags attribs) +#pragma warning restore CA1822 // Mark members as static { // TODO: Inlining } @@ -1146,7 +1142,9 @@ private CorInfoInline canInline(CORINFO_METHOD_STRUCT_* callerHnd, CORINFO_METHO } } +#pragma warning disable CA1822 // Mark members as static private void reportTailCallDecision(CORINFO_METHOD_STRUCT_* callerHnd, CORINFO_METHOD_STRUCT_* calleeHnd, bool fIsTailPrefix, CorInfoTailCall tailCallResult, byte* reason) +#pragma warning restore CA1822 // Mark members as static { } @@ -1355,10 +1353,7 @@ static CORINFO_RESOLVED_TOKEN CreateResolvedTokenFromMethod(CorInfoImpl jitInter CORINFO_RESOLVED_TOKEN result = default(CORINFO_RESOLVED_TOKEN); MethodILScope scope = jitInterface._compilation.GetMethodIL(methodWithToken.Method); - if (scope == null) - { - scope = Internal.IL.EcmaMethodILScope.Create((EcmaMethod)methodWithToken.Method.GetTypicalMethodDefinition()); - } + scope ??= EcmaMethodILScope.Create((EcmaMethod)methodWithToken.Method.GetTypicalMethodDefinition()); result.tokenScope = jitInterface.ObjectToHandle(scope); result.tokenContext = jitInterface.contextFromMethod(method); #if READYTORUN @@ -1432,7 +1427,7 @@ private CorInfoCallConvExtension getUnmanagedCallConv(CORINFO_METHOD_STRUCT_* me return callConv; } } - private CorInfoCallConvExtension GetUnmanagedCallConv(MethodDesc methodDesc, out bool suppressGCTransition) + private static CorInfoCallConvExtension GetUnmanagedCallConv(MethodDesc methodDesc, out bool suppressGCTransition) { UnmanagedCallingConventions callingConventions; @@ -1456,12 +1451,12 @@ private CorInfoCallConvExtension GetUnmanagedCallConv(MethodDesc methodDesc, out return ToCorInfoCallConvExtension(callingConventions, out suppressGCTransition); } - private CorInfoCallConvExtension GetUnmanagedCallConv(MethodSignature signature, out bool suppressGCTransition) + private static CorInfoCallConvExtension GetUnmanagedCallConv(MethodSignature signature, out bool suppressGCTransition) { return ToCorInfoCallConvExtension(signature.GetStandaloneMethodSignatureCallingConventions(), out suppressGCTransition); } - private CorInfoCallConvExtension ToCorInfoCallConvExtension(UnmanagedCallingConventions callConvs, out bool suppressGCTransition) + private static CorInfoCallConvExtension ToCorInfoCallConvExtension(UnmanagedCallingConventions callConvs, out bool suppressGCTransition) { CorInfoCallConvExtension result; switch (callConvs & UnmanagedCallingConventions.CallingConventionMask) @@ -1509,7 +1504,9 @@ private void setPatchpointInfo(PatchpointInfo* patchpointInfo) private PatchpointInfo* getOSRInfo(ref uint ilOffset) { throw new NotImplementedException("getOSRInfo"); } +#pragma warning disable CA1822 // Mark members as static private void methodMustBeLoadedBeforeCodeIsRun(CORINFO_METHOD_STRUCT_* method) +#pragma warning restore CA1822 // Mark members as static { } @@ -1551,9 +1548,9 @@ private static object ResolveTokenInScope(MethodILScope methodIL, object typeOrM if (owningMethod != typeOrMethodContext && owningMethod.IsCanonicalMethod(CanonicalFormKind.Any)) { - Instantiation typeInst = default; Instantiation methodInst = default; + Instantiation typeInst; if (typeOrMethodContext is TypeDesc typeContext) { Debug.Assert(typeContext.HasSameTypeDefinition(owningMethod.OwningType) || typeContext.IsArray); @@ -1606,7 +1603,7 @@ private object GetRuntimeDeterminedObjectForToken(ref CORINFO_RESOLVED_TOKEN pRe return result; } - private object GetRuntimeDeterminedObjectForToken(MethodILScope methodIL, object typeOrMethodContext, mdToken token) + private static object GetRuntimeDeterminedObjectForToken(MethodILScope methodIL, object typeOrMethodContext, mdToken token) { object result = ResolveTokenInScope(methodIL, typeOrMethodContext, token); @@ -1795,7 +1792,7 @@ private void findCallSiteSig(CORINFO_MODULE_STRUCT_* module, uint methTOK, CORIN return ObjectToHandle(_compilation.TypeSystemContext.GetWellKnownType(result)); } - private CorInfoCanSkipVerificationResult canSkipVerification(CORINFO_MODULE_STRUCT_* module) + private static CorInfoCanSkipVerificationResult canSkipVerification(CORINFO_MODULE_STRUCT_* module) { return CorInfoCanSkipVerificationResult.CORINFO_VERIFICATION_CAN_SKIP; } @@ -1896,7 +1893,9 @@ private bool isValueClass(CORINFO_CLASS_STRUCT_* cls) return HandleToObject(cls).IsValueType; } +#pragma warning disable CA1822 // Mark members as static private CorInfoInlineTypeCheck canInlineTypeCheck(CORINFO_CLASS_STRUCT_* cls, CorInfoInlineTypeCheckSource source) +#pragma warning restore CA1822 // Mark members as static { // TODO: when we support multiple modules at runtime, this will need to do more work // NOTE: cls can be null @@ -1993,12 +1992,16 @@ private uint getClassAttribsInternal(TypeDesc type) private byte* getAssemblyName(CORINFO_ASSEMBLY_STRUCT_* assem) { throw new NotImplementedException("getAssemblyName"); } +#pragma warning disable CA1822 // Mark members as static private void* LongLifetimeMalloc(UIntPtr sz) +#pragma warning restore CA1822 // Mark members as static { return (void*)Marshal.AllocCoTaskMem((int)sz); } +#pragma warning disable CA1822 // Mark members as static private void LongLifetimeFree(void* obj) +#pragma warning restore CA1822 // Mark members as static { Marshal.FreeCoTaskMem((IntPtr)obj); } @@ -2093,12 +2096,12 @@ public static int GetClassAlignmentRequirementStatic(DefType type) // // Heuristic to determine if we should have instances of this class 8 byte aligned // - static bool ShouldAlign8(int dwR8Fields, int dwTotalFields) + private static bool ShouldAlign8(int dwR8Fields, int dwTotalFields) { return dwR8Fields*2>dwTotalFields && dwR8Fields>=2; } - static bool ShouldAlign8(DefType type) + private static bool ShouldAlign8(DefType type) { int instanceFields = 0; int doubleFields = 0; @@ -2691,7 +2694,9 @@ private CorInfoType getChildType(CORINFO_CLASS_STRUCT_* clsHnd, CORINFO_CLASS_ST result = asCorInfoType(returnType, clsRet); } else +#pragma warning disable IDE0059 // Unnecessary assignment of a value clsRet = null; +#pragma warning restore IDE0059 // Unnecessary assignment of a value return result; } @@ -2746,7 +2751,9 @@ private CorInfoArrayIntrinsic getArrayIntrinsicID(CORINFO_METHOD_STRUCT_* ftn) return (void*)ObjectToHandle(_compilation.GetFieldRvaData(fd)); } +#pragma warning disable CA1822 // Mark members as static private CorInfoIsAccessAllowedResult canAccessClass(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, ref CORINFO_HELPER_DESC pAccessHelper) +#pragma warning restore CA1822 // Mark members as static { // TODO: Access check return CorInfoIsAccessAllowedResult.CORINFO_ACCESS_ALLOWED; @@ -2800,7 +2807,7 @@ private uint getFieldOffset(CORINFO_FIELD_STRUCT_* field) return (uint)fieldDesc.Offset.AsInt; } - private CORINFO_FIELD_ACCESSOR getFieldIntrinsic(FieldDesc field) + private static CORINFO_FIELD_ACCESSOR getFieldIntrinsic(FieldDesc field) { Debug.Assert(field.IsIntrinsic); @@ -2848,23 +2855,31 @@ private void getVars(CORINFO_METHOD_STRUCT_* ftn, ref uint cVars, ILVarInfo** va extendOthers = true; } +#pragma warning disable CA1822 // Mark members as static private void reportRichMappings(InlineTreeNode* inlineTree, uint numInlineTree, RichOffsetMapping* mappings, uint numMappings) +#pragma warning restore CA1822 // Mark members as static { Marshal.FreeHGlobal((IntPtr)inlineTree); Marshal.FreeHGlobal((IntPtr)mappings); } +#pragma warning disable CA1822 // Mark members as static private void* allocateArray(UIntPtr cBytes) +#pragma warning restore CA1822 // Mark members as static { return (void*)Marshal.AllocHGlobal((IntPtr)(void*)cBytes); } +#pragma warning disable CA1822 // Mark members as static private void freeArray(void* array) +#pragma warning restore CA1822 // Mark members as static { Marshal.FreeHGlobal((IntPtr)array); } +#pragma warning disable CA1822 // Mark members as static private CORINFO_ARG_LIST_STRUCT_* getArgNext(CORINFO_ARG_LIST_STRUCT_* args) +#pragma warning restore CA1822 // Mark members as static { return (CORINFO_ARG_LIST_STRUCT_*)((int)args + 1); } @@ -2872,7 +2887,7 @@ private void freeArray(void* array) private CorInfoTypeWithMod getArgType(CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_STRUCT_* args, CORINFO_CLASS_STRUCT_** vcTypeRet) { int index = (int)args; - Object sigObj = HandleToObject((IntPtr)sig->methodSignature); + object sigObj = HandleToObject((IntPtr)sig->methodSignature); MethodSignature methodSig = sigObj as MethodSignature; @@ -2897,7 +2912,7 @@ private CorInfoTypeWithMod getArgType(CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_ST private CORINFO_CLASS_STRUCT_* getArgClass(CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_STRUCT_* args) { int index = (int)args; - Object sigObj = HandleToObject((IntPtr)sig->methodSignature); + object sigObj = HandleToObject((IntPtr)sig->methodSignature); MethodSignature methodSig = sigObj as MethodSignature; if (methodSig != null) @@ -2933,7 +2948,9 @@ private HRESULT GetErrorHRESULT(_EXCEPTION_POINTERS* pExceptionPointers) private uint GetErrorMessage(char* buffer, uint bufferLength) { throw new NotImplementedException("GetErrorMessage"); } +#pragma warning disable CA1822 // Mark members as static private int FilterException(_EXCEPTION_POINTERS* pExceptionPointers) +#pragma warning restore CA1822 // Mark members as static { // This method is completely handled by the C++ wrapper to the JIT-EE interface, // and should never reach the managed implementation. @@ -2941,7 +2958,9 @@ private int FilterException(_EXCEPTION_POINTERS* pExceptionPointers) throw new NotSupportedException("FilterException"); } +#pragma warning disable CA1822 // Mark members as static private bool runWithErrorTrap(void* function, void* parameter) +#pragma warning restore CA1822 // Mark members as static { // This method is completely handled by the C++ wrapper to the JIT-EE interface, // and should never reach the managed implementation. @@ -2949,7 +2968,9 @@ private bool runWithErrorTrap(void* function, void* parameter) throw new NotSupportedException("runWithErrorTrap"); } +#pragma warning disable CA1822 // Mark members as static private bool runWithSPMIErrorTrap(void* function, void* parameter) +#pragma warning restore CA1822 // Mark members as static { // This method is completely handled by the C++ wrapper to the JIT-EE interface, // and should never reach the managed implementation. @@ -2970,7 +2991,7 @@ public static CORINFO_OS TargetToOs(TargetDetails target) private void getEEInfo(ref CORINFO_EE_INFO pEEInfoOut) { - pEEInfoOut = new CORINFO_EE_INFO(); + pEEInfoOut = default(CORINFO_EE_INFO); #if DEBUG // In debug, write some bogus data to the struct to ensure we have filled everything @@ -2997,7 +3018,9 @@ private void getEEInfo(ref CORINFO_EE_INFO pEEInfoOut) pEEInfoOut.osType = TargetToOs(_compilation.NodeFactory.Target); } +#pragma warning disable CA1822 // Mark members as static private char* getJitTimeLogFilename() +#pragma warning restore CA1822 // Mark members as static { return null; } @@ -3048,14 +3071,13 @@ private static byte[] StringToUTF8(string s) return (byte*)GetPin(StringToUTF8(method.Name)); } - private String getMethodNameFromMetadataImpl(MethodDesc method, out string className, out string namespaceName, out string enclosingClassName) + private static string getMethodNameFromMetadataImpl(MethodDesc method, out string className, out string namespaceName, out string enclosingClassName) { - string result = null; className = null; namespaceName = null; enclosingClassName = null; - result = method.Name; + string result = method.Name; MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) @@ -3148,7 +3170,9 @@ private uint getThreadTLSIndex(ref void* ppIndirection) private void getFunctionFixedEntryPoint(CORINFO_METHOD_STRUCT_* ftn, bool isUnsafeFunctionPointer, ref CORINFO_CONST_LOOKUP pResult) { throw new NotImplementedException("getFunctionFixedEntryPoint"); } +#pragma warning disable CA1822 // Mark members as static private CorInfoHelpFunc getLazyStringLiteralHelper(CORINFO_MODULE_STRUCT_* handle) +#pragma warning restore CA1822 // Mark members as static { // TODO: Lazy string literal helper return CorInfoHelpFunc.CORINFO_HELP_UNDEF; @@ -3160,7 +3184,7 @@ private CorInfoHelpFunc getLazyStringLiteralHelper(CORINFO_MODULE_STRUCT_* handl private CORINFO_FIELD_STRUCT_* embedFieldHandle(CORINFO_FIELD_STRUCT_* handle, ref void* ppIndirection) { throw new NotImplementedException("embedFieldHandle"); } - private CORINFO_RUNTIME_LOOKUP_KIND GetGenericRuntimeLookupKind(MethodDesc method) + private static CORINFO_RUNTIME_LOOKUP_KIND GetGenericRuntimeLookupKind(MethodDesc method) { if (method.RequiresInstMethodDescArg()) return CORINFO_RUNTIME_LOOKUP_KIND.CORINFO_LOOKUP_METHODPARAM; @@ -3191,7 +3215,9 @@ private void getLocationOfThisType(CORINFO_METHOD_STRUCT_* context, ref CORINFO_ private void* GetCookieForPInvokeCalliSig(CORINFO_SIG_INFO* szMetaSig, ref void* ppIndirection) { throw new NotImplementedException("GetCookieForPInvokeCalliSig"); } +#pragma warning disable CA1822 // Mark members as static private CORINFO_JUST_MY_CODE_HANDLE_* getJustMyCodeHandle(CORINFO_METHOD_STRUCT_* method, ref CORINFO_JUST_MY_CODE_HANDLE_* ppIndirection) +#pragma warning restore CA1822 // Mark members as static { ppIndirection = null; return null; @@ -3204,7 +3230,7 @@ private void GetProfilingHandle(ref bool pbHookFunction, ref void* pProfilerHand /// private CORINFO_CONST_LOOKUP CreateConstLookupToSymbol(ISymbolNode symbol) { - CORINFO_CONST_LOOKUP constLookup = new CORINFO_CONST_LOOKUP(); + CORINFO_CONST_LOOKUP constLookup = default(CORINFO_CONST_LOOKUP); constLookup.addr = (void*)ObjectToHandle(symbol); constLookup.accessType = symbol.RepresentsIndirectionCell ? InfoAccessType.IAT_PVALUE : InfoAccessType.IAT_VALUE; return constLookup; @@ -3263,7 +3289,9 @@ private void addActiveDependency(CORINFO_MODULE_STRUCT_* moduleFrom, CORINFO_MOD private void MethodCompileComplete(CORINFO_METHOD_STRUCT_* methHnd) { throw new NotImplementedException("MethodCompileComplete"); } +#pragma warning disable CA1822 // Mark members as static private bool getTailCallHelpers(ref CORINFO_RESOLVED_TOKEN callToken, CORINFO_SIG_INFO* sig, CORINFO_GET_TAILCALL_HELPERS_FLAGS flags, ref CORINFO_TAILCALL_HELPERS pResult) +#pragma warning restore CA1822 // Mark members as static { // Slow tailcalls are not supported yet // https://github.com/dotnet/runtime/issues/35423 @@ -3385,7 +3413,9 @@ private void allocUnwindInfo(byte* pHotCode, byte* pColdCode, uint startOffset, return (void*)GetPin(_gcInfo); } +#pragma warning disable CA1822 // Mark members as static private bool logMsg(uint level, byte* fmt, IntPtr args) +#pragma warning restore CA1822 // Mark members as static { // Console.WriteLine(Marshal.PtrToStringUTF8((IntPtr)fmt)); return false; @@ -3399,13 +3429,17 @@ private int doAssert(byte* szFile, int iLine, byte* szExpr) return 1; } +#pragma warning disable CA1822 // Mark members as static private void reportFatalError(CorJitResult result) +#pragma warning restore CA1822 // Mark members as static { // We could add some logging here, but for now it's unnecessary. // CompileMethod is going to fail with this CorJitResult anyway. } +#pragma warning disable CA1822 // Mark members as static private void recordCallSite(uint instrOffset, CORINFO_SIG_INFO* callSig, CORINFO_METHOD_STRUCT_* methodHandle) +#pragma warning restore CA1822 // Mark members as static { } @@ -3607,13 +3641,13 @@ private ushort getRelocTypeHint(void* target) switch (_compilation.TypeSystemContext.Target.Architecture) { case TargetArchitecture.X64: - return (ushort)ILCompiler.DependencyAnalysis.RelocType.IMAGE_REL_BASED_REL32; + return (ushort)RelocType.IMAGE_REL_BASED_REL32; case TargetArchitecture.ARM: - return (ushort)ILCompiler.DependencyAnalysis.RelocType.IMAGE_REL_BASED_THUMB_BRANCH24; + return (ushort)RelocType.IMAGE_REL_BASED_THUMB_BRANCH24; default: - return UInt16.MaxValue; + return ushort.MaxValue; } } @@ -3851,11 +3885,13 @@ private HRESULT getPgoInstrumentationResults(CORINFO_METHOD_STRUCT_* ftnHnd, ref } else { +#pragma warning disable SA1001, SA1113, SA1115 // Commas should be spaced correctly ComputeJitPgoInstrumentationSchema(ObjectToHandle, pgoResultsSchemas, out var nativeSchemas, out var instrumentationData #if !READYTORUN , _compilation.CanConstructType #endif ); +#pragma warning restore SA1001, SA1113, SA1115 // Commas should be spaced correctly pgoResults.pInstrumentationData = (byte*)GetPin(instrumentationData); pgoResults.countSchemaItems = (uint)nativeSchemas.Length; diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs b/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs index d903e7d6faf06..78eec3e129759 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs @@ -5,11 +5,9 @@ // FROM /src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txt // using /src/coreclr/tools/Common/JitInterface/ThunkGenerator/gen.bat -using System; using System.Collections; using System.Collections.Generic; using System.Linq; -using System.Runtime.InteropServices; using Internal.TypeSystem; namespace Internal.JitInterface @@ -338,7 +336,7 @@ IEnumerator IEnumerable.GetEnumerator() public IEnumerator GetEnumerator() { - for (int i = 1; i < (int)InstructionSet.NONE; i ++) + for (int i = 1; i < (int)InstructionSet.NONE; i++) { InstructionSet instructionSet = (InstructionSet)i; if (HasInstructionSet(instructionSet)) @@ -384,12 +382,12 @@ public static InstructionSet ConvertToImpliedInstructionSetForVectorInstructionS public static InstructionSetFlags ExpandInstructionSetByImplicationHelper(TargetArchitecture architecture, InstructionSetFlags input) { - InstructionSetFlags oldflags = input; + InstructionSetFlags oldflags; InstructionSetFlags resultflags = input; do { oldflags = resultflags; - switch(architecture) + switch (architecture) { case TargetArchitecture.ARM64: @@ -619,7 +617,7 @@ public void ExpandInstructionSetByReverseImplication(TargetArchitecture architec private static InstructionSetFlags ExpandInstructionSetByReverseImplicationHelper(TargetArchitecture architecture, InstructionSetFlags input) { - InstructionSetFlags oldflags = input; + InstructionSetFlags oldflags; InstructionSetFlags resultflags = input; do { diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoTypes.VarInfo.cs b/src/coreclr/tools/Common/JitInterface/CorInfoTypes.VarInfo.cs index ff85f537803fe..cd6d82f8f511e 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoTypes.VarInfo.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoTypes.VarInfo.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Diagnostics; using System.Runtime.InteropServices; // diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs b/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs index 4d054a1074494..66fac586cb31a 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs @@ -5,7 +5,6 @@ using System.Diagnostics; using System.Runtime.InteropServices; using Internal.Pgo; -using Internal.TypeSystem; namespace Internal.JitInterface { @@ -889,10 +888,10 @@ public enum CORINFO_TAILCALL_HELPERS_FLAGS [StructLayout(LayoutKind.Sequential)] public unsafe struct CORINFO_TAILCALL_HELPERS { - CORINFO_TAILCALL_HELPERS_FLAGS flags; - CORINFO_METHOD_STRUCT_* hStoreArgs; - CORINFO_METHOD_STRUCT_* hCallTarget; - CORINFO_METHOD_STRUCT_* hDispatcher; + private CORINFO_TAILCALL_HELPERS_FLAGS flags; + private CORINFO_METHOD_STRUCT_* hStoreArgs; + private CORINFO_METHOD_STRUCT_* hCallTarget; + private CORINFO_METHOD_STRUCT_* hDispatcher; }; public enum CORINFO_THIS_TRANSFORM @@ -1432,7 +1431,7 @@ public enum CorJitFlag : uint public struct CORJIT_FLAGS { - private UInt64 _corJitFlags; + private ulong _corJitFlags; public InstructionSetFlags InstructionSetFlags; public void Reset() diff --git a/src/coreclr/tools/Common/JitInterface/JitConfigProvider.cs b/src/coreclr/tools/Common/JitInterface/JitConfigProvider.cs index 898ec59e5a5d3..2605d5489dea4 100644 --- a/src/coreclr/tools/Common/JitInterface/JitConfigProvider.cs +++ b/src/coreclr/tools/Common/JitInterface/JitConfigProvider.cs @@ -6,7 +6,6 @@ using System.Diagnostics; using System.Runtime.InteropServices; using System.Threading; -using ILCompiler; using Internal.TypeSystem; using NumberStyles = System.Globalization.NumberStyles; @@ -79,7 +78,7 @@ public IntPtr UnmanagedInstance /// A collection of parameter name/value pairs. public JitConfigProvider(IEnumerable jitFlags, IEnumerable> parameters) { - ArrayBuilder jitFlagBuilder = new ArrayBuilder(); + ArrayBuilder jitFlagBuilder = default(ArrayBuilder); foreach (CorJitFlag jitFlag in jitFlags) { jitFlagBuilder.Add(jitFlag); @@ -110,7 +109,7 @@ public int GetIntConfigValue(string name, int defaultValue) string stringValue; int intValue; if (_config.TryGetValue(name, out stringValue) && - Int32.TryParse(stringValue, NumberStyles.AllowHexSpecifier, null, out intValue)) + int.TryParse(stringValue, NumberStyles.AllowHexSpecifier, null, out intValue)) { return intValue; } @@ -126,7 +125,7 @@ public string GetStringConfigValue(string name) return stringValue; } - return String.Empty; + return string.Empty; } private static string GetTargetSpec(TargetDetails target) diff --git a/src/coreclr/tools/Common/JitInterface/LoongArch64PassStructInRegister.cs b/src/coreclr/tools/Common/JitInterface/LoongArch64PassStructInRegister.cs index 0a164d23ebee1..88125fe5bad7f 100644 --- a/src/coreclr/tools/Common/JitInterface/LoongArch64PassStructInRegister.cs +++ b/src/coreclr/tools/Common/JitInterface/LoongArch64PassStructInRegister.cs @@ -1,9 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Generic; using System.Diagnostics; -using ILCompiler; using Internal.TypeSystem; namespace Internal.JitInterface @@ -20,10 +18,7 @@ public static uint GetLoongArch64PassStructInRegisterFlags(TypeDesc typeDesc) { if (!field.IsStatic) { - if (firstField == null) - { - firstField = field; - } + firstField ??= field; numIntroducedFields++; } } @@ -95,7 +90,7 @@ public static uint GetLoongArch64PassStructInRegisterFlags(TypeDesc typeDesc) } else if ((floatFieldFlags & (uint)StructFloatFieldInfoFlags.STRUCT_FLOAT_FIELD_FIRST) != 0) { - floatFieldFlags = floatFieldFlags ^ (uint)StructFloatFieldInfoFlags.STRUCT_MERGE_FIRST_SECOND_8; + floatFieldFlags ^= (uint)StructFloatFieldInfoFlags.STRUCT_MERGE_FIRST_SECOND_8; } else { diff --git a/src/coreclr/tools/Common/JitInterface/MemoryHelper.cs b/src/coreclr/tools/Common/JitInterface/MemoryHelper.cs index ce7edb1e56be3..ac009bcd17da1 100644 --- a/src/coreclr/tools/Common/JitInterface/MemoryHelper.cs +++ b/src/coreclr/tools/Common/JitInterface/MemoryHelper.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace Internal.JitInterface { internal static unsafe class MemoryHelper diff --git a/src/coreclr/tools/Common/JitInterface/SystemVStructClassificator.cs b/src/coreclr/tools/Common/JitInterface/SystemVStructClassificator.cs index 1237cdb3dd34e..e8c1a01f86022 100644 --- a/src/coreclr/tools/Common/JitInterface/SystemVStructClassificator.cs +++ b/src/coreclr/tools/Common/JitInterface/SystemVStructClassificator.cs @@ -5,12 +5,11 @@ using System.Diagnostics; using ILCompiler; using Internal.TypeSystem; +using static Internal.JitInterface.SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR; +using static Internal.JitInterface.SystemVClassificationType; namespace Internal.JitInterface { - using static SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR; - using static SystemVClassificationType; - internal static class SystemVStructClassificator { private struct SystemVStructRegisterPassingHelper @@ -65,7 +64,7 @@ internal SystemVStructRegisterPassingHelper(int totalStructSize) public int[] FieldOffsets; }; - private class FieldEnumerator + private static class FieldEnumerator { internal static IEnumerable GetInstanceFields(TypeDesc typeDesc, bool isFixedBuffer, int numIntroducedFields) { @@ -167,7 +166,7 @@ private static SystemVClassificationType TypeDef2SystemVClassification(TypeDesc // If we have a field classification already, but there is a union, we must merge the classification type of the field. Returns the // new, merged classification type. - static SystemVClassificationType ReClassifyField(SystemVClassificationType originalClassification, SystemVClassificationType newFieldClassification) + private static SystemVClassificationType ReClassifyField(SystemVClassificationType originalClassification, SystemVClassificationType newFieldClassification) { Debug.Assert((newFieldClassification == SystemVClassificationTypeInteger) || (newFieldClassification == SystemVClassificationTypeIntegerReference) || @@ -226,10 +225,7 @@ private static bool ClassifyEightBytes(TypeDesc typeDesc, { if (!field.IsStatic) { - if (firstField == null) - { - firstField = field; - } + firstField ??= field; numIntroducedFields++; } } diff --git a/src/coreclr/tools/Common/JitInterface/TypeString.cs b/src/coreclr/tools/Common/JitInterface/TypeString.cs index db60084315132..7bdb02e08107f 100644 --- a/src/coreclr/tools/Common/JitInterface/TypeString.cs +++ b/src/coreclr/tools/Common/JitInterface/TypeString.cs @@ -10,7 +10,7 @@ namespace Internal.JitInterface // This is a very rough equivalent of typestring.cpp in the CLR. // There's way more rules to capture. Hopefully, we'll only ever need this in the code to recognize SIMD intrisics // and we won't need to replicate all the details around escaping and such. - internal class TypeString : TypeNameFormatter + internal sealed class TypeString : TypeNameFormatter { public static TypeString Instance { get; } = new TypeString(); @@ -29,7 +29,7 @@ public override void AppendName(StringBuilder sb, GenericParameterDesc type) public override void AppendName(StringBuilder sb, SignatureTypeVariable type) { - sb.Append("!"); + sb.Append('!'); sb.Append(type.Index); } @@ -59,7 +59,7 @@ public override void AppendName(StringBuilder sb, FunctionPointerType type) public override void AppendName(StringBuilder sb, ByRefType type) { AppendName(sb, type.ParameterType); - sb.Append("&"); + sb.Append('&'); } public override void AppendName(StringBuilder sb, ArrayType type) diff --git a/src/coreclr/tools/Common/JitInterface/UnboxingMethodDesc.cs b/src/coreclr/tools/Common/JitInterface/UnboxingMethodDesc.cs index 0db82ff37eb0f..e21794718c8b2 100644 --- a/src/coreclr/tools/Common/JitInterface/UnboxingMethodDesc.cs +++ b/src/coreclr/tools/Common/JitInterface/UnboxingMethodDesc.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Generic; using System.Diagnostics; using Internal.TypeSystem; @@ -13,7 +12,7 @@ namespace Internal.JitInterface /// This class is for internal purposes within the JitInterface. It's not expected /// for it to escape the JitInterface. /// - internal class UnboxingMethodDesc : MethodDelegator + internal sealed class UnboxingMethodDesc : MethodDelegator { private readonly UnboxingMethodDescFactory _factory; diff --git a/src/coreclr/tools/Common/JitInterface/UnboxingMethodDescFactory.cs b/src/coreclr/tools/Common/JitInterface/UnboxingMethodDescFactory.cs index 4f38998f5cb5f..457f2fa87259a 100644 --- a/src/coreclr/tools/Common/JitInterface/UnboxingMethodDescFactory.cs +++ b/src/coreclr/tools/Common/JitInterface/UnboxingMethodDescFactory.cs @@ -1,14 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; -using System.Diagnostics; using Internal.TypeSystem; namespace Internal.JitInterface { - internal class UnboxingMethodDescFactory : Dictionary + internal sealed class UnboxingMethodDescFactory : Dictionary { public UnboxingMethodDesc GetUnboxingMethod(MethodDesc method) { diff --git a/src/coreclr/tools/Common/Pgo/PgoFormat.cs b/src/coreclr/tools/Common/Pgo/PgoFormat.cs index 5dc847b34810b..fa4fe3c1a3180 100644 --- a/src/coreclr/tools/Common/Pgo/PgoFormat.cs +++ b/src/coreclr/tools/Common/Pgo/PgoFormat.cs @@ -5,8 +5,6 @@ using System.Collections; using System.Collections.Generic; using System.Diagnostics; -using System.Text.RegularExpressions; -using ILCompiler; namespace Internal.Pgo { @@ -113,8 +111,8 @@ private enum InstrumentationDataProcessingState public class PgoEncodedCompressedIntParser : IEnumerable, IEnumerator { - long _current; - byte[] _bytes; + private long _current; + private byte[] _bytes; public PgoEncodedCompressedIntParser(byte[] bytes, int startOffset) { @@ -319,7 +317,7 @@ public static IEnumerable ParsePgoData(IPgoSchema else curSchema.ILOffset = checked((int)value); - processingState = processingState & ~InstrumentationDataProcessingState.ILOffset; + processingState &= ~InstrumentationDataProcessingState.ILOffset; } else if ((processingState & InstrumentationDataProcessingState.Type) == InstrumentationDataProcessingState.Type) { @@ -328,7 +326,7 @@ public static IEnumerable ParsePgoData(IPgoSchema else curSchema.InstrumentationKind = (PgoInstrumentationKind)value; - processingState = processingState & ~InstrumentationDataProcessingState.Type; + processingState &= ~InstrumentationDataProcessingState.Type; } else if ((processingState & InstrumentationDataProcessingState.Count) == InstrumentationDataProcessingState.Count) { @@ -336,7 +334,7 @@ public static IEnumerable ParsePgoData(IPgoSchema curSchema.Count = checked((int)(value + (long)curSchema.Count)); else curSchema.Count = checked((int)value); - processingState = processingState & ~InstrumentationDataProcessingState.Count; + processingState &= ~InstrumentationDataProcessingState.Count; } else if ((processingState & InstrumentationDataProcessingState.Other) == InstrumentationDataProcessingState.Other) { @@ -344,7 +342,7 @@ public static IEnumerable ParsePgoData(IPgoSchema curSchema.Other = checked((int)(value + (long)curSchema.Other)); else curSchema.Other = checked((int)value); - processingState = processingState & ~InstrumentationDataProcessingState.Other; + processingState &= ~InstrumentationDataProcessingState.Other; } if (processingState == InstrumentationDataProcessingState.Done) @@ -412,13 +410,13 @@ public static void EncodePgoData(IEnumerable sche if (!emitAllElementsUnconditionally) { if (ilOffsetDiff != 0) - modifyMask = modifyMask | InstrumentationDataProcessingState.ILOffset; + modifyMask |= InstrumentationDataProcessingState.ILOffset; if (TypeDiff != 0) - modifyMask = modifyMask | InstrumentationDataProcessingState.Type; + modifyMask |= InstrumentationDataProcessingState.Type; if (CountDiff != 0) - modifyMask = modifyMask | InstrumentationDataProcessingState.Count; + modifyMask |= InstrumentationDataProcessingState.Count; if (OtherDiff != 0) - modifyMask = modifyMask | InstrumentationDataProcessingState.Other; + modifyMask |= InstrumentationDataProcessingState.Other; } else { @@ -511,7 +509,7 @@ public static void EncodePgoData(IEnumerable sche } - private class PgoSchemaMergeComparer : IComparer, IEqualityComparer + private sealed class PgoSchemaMergeComparer : IComparer, IEqualityComparer { public static PgoSchemaMergeComparer Singleton = new PgoSchemaMergeComparer(); @@ -563,7 +561,7 @@ public static PgoSchemaElem[] Merge(ReadOnlySpan(ReadOnlySpan dataMerger, PgoSchemaElem schema) + static void MergeInSchemaElem(Dictionary dataMerger, PgoSchemaElem schema) { if (dataMerger.TryGetValue(schema, out var existingSchemaItem)) { @@ -648,7 +646,7 @@ void MergeInSchemaElem(Dictionary dataMerger, PgoS } Debug.Assert(PgoSchemaMergeComparer.Singleton.Compare(schema, mergedElem) == 0); - Debug.Assert(PgoSchemaMergeComparer.Singleton.Equals(schema, mergedElem) == true); + Debug.Assert(PgoSchemaMergeComparer.Singleton.Equals(schema, mergedElem)); dataMerger[mergedElem] = mergedElem; } else diff --git a/src/coreclr/tools/Common/Pgo/TypeSystemEntityOrUnknown.cs b/src/coreclr/tools/Common/Pgo/TypeSystemEntityOrUnknown.cs index 6eabe55cf7cc5..2a064ebf03209 100644 --- a/src/coreclr/tools/Common/Pgo/TypeSystemEntityOrUnknown.cs +++ b/src/coreclr/tools/Common/Pgo/TypeSystemEntityOrUnknown.cs @@ -23,7 +23,7 @@ public TypeSystemEntityOrUnknown(MethodDesc method) _data = method; } - readonly object _data; + private readonly object _data; public TypeDesc AsType => _data as TypeDesc; public MethodDesc AsMethod => _data as MethodDesc; public FieldDesc AsField => _data as FieldDesc; @@ -39,7 +39,7 @@ public bool Equals(TypeSystemEntityOrUnknown other) } else { - return object.ReferenceEquals(_data, other._data); + return ReferenceEquals(_data, other._data); } } diff --git a/src/coreclr/tools/Common/Sorting/ISortableDataStructureAccessor.cs b/src/coreclr/tools/Common/Sorting/ISortableDataStructureAccessor.cs index e6699d4d0febb..c2ec9f24b84f9 100644 --- a/src/coreclr/tools/Common/Sorting/ISortableDataStructureAccessor.cs +++ b/src/coreclr/tools/Common/Sorting/ISortableDataStructureAccessor.cs @@ -1,10 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - namespace ILCompiler { internal interface ISortableDataStructureAccessor diff --git a/src/coreclr/tools/Common/Sorting/ListAccessor.cs b/src/coreclr/tools/Common/Sorting/ListAccessor.cs index 962bd3f38a008..f26f1ff5acaa8 100644 --- a/src/coreclr/tools/Common/Sorting/ListAccessor.cs +++ b/src/coreclr/tools/Common/Sorting/ListAccessor.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; namespace ILCompiler.Sorting.Implementation diff --git a/src/coreclr/tools/Common/Sorting/MergeSort.cs b/src/coreclr/tools/Common/Sorting/MergeSort.cs index cbf5d1da814b0..7faf01aeafb5b 100644 --- a/src/coreclr/tools/Common/Sorting/MergeSort.cs +++ b/src/coreclr/tools/Common/Sorting/MergeSort.cs @@ -61,7 +61,7 @@ public static void MergeSortAllowDuplicates(this T[] arrayToSort, IComparer delegates instead of IComparer instances private struct ComparisonWrapper : IComparer { - Comparison _comparison; + private Comparison _comparison; public ComparisonWrapper(Comparison comparison) { _comparison = comparison; diff --git a/src/coreclr/tools/Common/Sorting/MergeSortCore.cs b/src/coreclr/tools/Common/Sorting/MergeSortCore.cs index 6998c99737916..b69e733d3aa70 100644 --- a/src/coreclr/tools/Common/Sorting/MergeSortCore.cs +++ b/src/coreclr/tools/Common/Sorting/MergeSortCore.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -44,8 +43,8 @@ private static async Task ParallelSort(TDataStructure arrayToSort, int index, in T[] localCopyOfHalfOfArray = new T[halfLen]; accessor.Copy(arrayToSort, index, localCopyOfHalfOfArray, 0, halfLen); - await MergeSortCore, TComparer, TCompareAsEqualAction>.ParallelSort(localCopyOfHalfOfArray, 0, halfLen, comparer); - await rightSortTask; + await MergeSortCore, TComparer, TCompareAsEqualAction>.ParallelSort(localCopyOfHalfOfArray, 0, halfLen, comparer).ConfigureAwait(true); + await rightSortTask.ConfigureAwait(true); Merge(localCopyOfHalfOfArray, arrayToSort, index, halfLen, length, comparer); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/ArrayType.Canon.cs b/src/coreclr/tools/Common/TypeSystem/Canon/ArrayType.Canon.cs index 7deba06d193c2..5689f6101853d 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/ArrayType.Canon.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/ArrayType.Canon.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Implements canonicalization for arrays - partial class ArrayType + public partial class ArrayType { protected override TypeDesc ConvertToCanonFormImpl(CanonicalFormKind kind) { @@ -21,7 +21,7 @@ protected override TypeDesc ConvertToCanonFormImpl(CanonicalFormKind kind) } // Implements canonicalization for array methods - partial class ArrayMethod + public partial class ArrayMethod { public override bool IsCanonicalMethod(CanonicalFormKind policy) { diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/ByRefType.Canon.cs b/src/coreclr/tools/Common/TypeSystem/Canon/ByRefType.Canon.cs index 97513cb08e4bd..53c01d00bbe11 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/ByRefType.Canon.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/ByRefType.Canon.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Implements canonicalizing ByRefs - partial class ByRefType + public partial class ByRefType { protected override TypeDesc ConvertToCanonFormImpl(CanonicalFormKind kind) { diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Diagnostic.cs b/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Diagnostic.cs index d8906a8a7dfb1..2a6843397b602 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Diagnostic.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Diagnostic.cs @@ -1,13 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; - -using Internal.NativeFormat; - -using Debug = System.Diagnostics.Debug; - namespace Internal.TypeSystem { internal sealed partial class CanonType diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Interop.cs b/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Interop.cs index c5e1e39bc977a..6897279ac030a 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Interop.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Interop.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem { - partial class CanonBaseType + public partial class CanonBaseType { public override PInvokeStringFormat PInvokeStringFormat => default(PInvokeStringFormat); } diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Sorting.cs index 8646ad432b446..32e4db3bab9e1 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Sorting.cs @@ -6,7 +6,7 @@ namespace Internal.TypeSystem { // Functionality related to deterministic ordering of types - partial class CanonBaseType + public partial class CanonBaseType { protected internal sealed override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer) { @@ -16,12 +16,12 @@ protected internal sealed override int CompareToImpl(TypeDesc other, TypeSystemC } } - partial class CanonType + internal partial class CanonType { protected internal override int ClassCode => 46114331; } - partial class UniversalCanonType + internal partial class UniversalCanonType { protected internal override int ClassCode => 1687626054; } diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/DefType.Canon.cs b/src/coreclr/tools/Common/TypeSystem/Canon/DefType.Canon.cs index 3d783352c1809..7c959d1c3a6cd 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/DefType.Canon.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/DefType.Canon.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Implements canonicalization handling for TypeDefs - partial class DefType + public partial class DefType { protected override TypeDesc ConvertToCanonFormImpl(CanonicalFormKind kind) { diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/FunctionPointerType.Canon.cs b/src/coreclr/tools/Common/TypeSystem/Canon/FunctionPointerType.Canon.cs index 8ff4c2ee544d3..ce0f96f7990bd 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/FunctionPointerType.Canon.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/FunctionPointerType.Canon.cs @@ -1,12 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace Internal.TypeSystem { // Holds code for canonicalizing a function pointer type - partial class FunctionPointerType + public partial class FunctionPointerType { public override bool IsCanonicalSubtype(CanonicalFormKind policy) { diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/InstantiatedMethod.Canon.cs b/src/coreclr/tools/Common/TypeSystem/Canon/InstantiatedMethod.Canon.cs index 263615253fa0c..a5cb3efa1cb21 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/InstantiatedMethod.Canon.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/InstantiatedMethod.Canon.cs @@ -6,14 +6,14 @@ namespace Internal.TypeSystem { // Implements generic method canonicalization - partial class InstantiatedMethod + public partial class InstantiatedMethod { /// /// Stores a cached version of the canonicalized form of this method since /// calculating it is a recursive operation /// - InstantiatedMethod _specificCanonCache; - InstantiatedMethod _universalCanonCache; + private InstantiatedMethod _specificCanonCache; + private InstantiatedMethod _universalCanonCache; /// /// Returns the result of canonicalizing this method over the given kind of Canon @@ -52,7 +52,7 @@ public override MethodDesc GetCanonMethodTarget(CanonicalFormKind kind) return canonicalMethodResult; } - InstantiatedMethod GetCachedCanonValue(CanonicalFormKind kind) + private InstantiatedMethod GetCachedCanonValue(CanonicalFormKind kind) { switch (kind) { @@ -68,7 +68,7 @@ InstantiatedMethod GetCachedCanonValue(CanonicalFormKind kind) } } - void SetCachedCanonValue(CanonicalFormKind kind, InstantiatedMethod value) + private void SetCachedCanonValue(CanonicalFormKind kind, InstantiatedMethod value) { switch (kind) { diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/InstantiatedType.Canon.cs b/src/coreclr/tools/Common/TypeSystem/Canon/InstantiatedType.Canon.cs index 5bbbffc42f925..d57b2e19f9b9f 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/InstantiatedType.Canon.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/InstantiatedType.Canon.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Implements canonicalization for generic instantiations - partial class InstantiatedType + public partial class InstantiatedType { public override bool IsCanonicalSubtype(CanonicalFormKind policy) { diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/MetadataType.Canon.cs b/src/coreclr/tools/Common/TypeSystem/Canon/MetadataType.Canon.cs index 2d9d4d45e1069..7763791647040 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/MetadataType.Canon.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/MetadataType.Canon.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Holds code for canonicalization of metadata types - partial class MetadataType + public partial class MetadataType { public override bool IsCanonicalSubtype(CanonicalFormKind policy) { diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/MethodDelegator.Canon.cs b/src/coreclr/tools/Common/TypeSystem/Canon/MethodDelegator.Canon.cs index 9b89c40353e0c..e4e5211d08a95 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/MethodDelegator.Canon.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/MethodDelegator.Canon.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem { - partial class MethodDelegator + public partial class MethodDelegator { public override bool IsCanonicalMethod(CanonicalFormKind policy) { diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/MethodDesc.Canon.cs b/src/coreclr/tools/Common/TypeSystem/Canon/MethodDesc.Canon.cs index 0189311657e55..00e0d6859ffd8 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/MethodDesc.Canon.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/MethodDesc.Canon.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Implements method canonicalization - partial class MethodDesc + public partial class MethodDesc { public virtual bool IsCanonicalMethod(CanonicalFormKind policy) { diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/MethodForInstantiatedType.Canon.cs b/src/coreclr/tools/Common/TypeSystem/Canon/MethodForInstantiatedType.Canon.cs index ec81730a0a878..2125dd63c1994 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/MethodForInstantiatedType.Canon.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/MethodForInstantiatedType.Canon.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Implements canonicalization for methods on instantiated types - partial class MethodForInstantiatedType + public partial class MethodForInstantiatedType { public override bool IsCanonicalMethod(CanonicalFormKind policy) { diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/ParameterizedType.Canon.cs b/src/coreclr/tools/Common/TypeSystem/Canon/ParameterizedType.Canon.cs index a66eeb39d88fe..774c1ce60f2dd 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/ParameterizedType.Canon.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/ParameterizedType.Canon.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Holds code for canonicalizing a parameterized type - partial class ParameterizedType + public partial class ParameterizedType { public sealed override bool IsCanonicalSubtype(CanonicalFormKind policy) { diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/PointerType.Canon.cs b/src/coreclr/tools/Common/TypeSystem/Canon/PointerType.Canon.cs index 28e35a96a2c78..f3dee20511c33 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/PointerType.Canon.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/PointerType.Canon.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Holds code for canonicalizing pointers - partial class PointerType + public partial class PointerType { protected override TypeDesc ConvertToCanonFormImpl(CanonicalFormKind kind) { diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/SignatureVariable.Canon.cs b/src/coreclr/tools/Common/TypeSystem/Canon/SignatureVariable.Canon.cs index 2e76e9eed0677..d6675b5d4f796 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/SignatureVariable.Canon.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/SignatureVariable.Canon.cs @@ -6,7 +6,7 @@ namespace Internal.TypeSystem { // Implements canonicalization of generic type parameters - partial class SignatureTypeVariable + public partial class SignatureTypeVariable { public override bool IsCanonicalSubtype(CanonicalFormKind policy) { @@ -22,7 +22,7 @@ protected override TypeDesc ConvertToCanonFormImpl(CanonicalFormKind kind) } // Implements canonicalization of generic method parameters - partial class SignatureMethodVariable + public partial class SignatureMethodVariable { public override bool IsCanonicalSubtype(CanonicalFormKind policy) { diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/TypeDesc.Canon.cs b/src/coreclr/tools/Common/TypeSystem/Canon/TypeDesc.Canon.cs index c0ce80263aad8..0fbd5ecbbbb50 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/TypeDesc.Canon.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/TypeDesc.Canon.cs @@ -6,15 +6,16 @@ namespace Internal.TypeSystem { // Implements canonicalization for types - partial class TypeDesc + public partial class TypeDesc { /// /// Stores a cached version of the canonicalized form of this type since /// calculating it is a recursive operation /// - TypeDesc _specificCanonCache; - TypeDesc _universalCanonCache; - TypeDesc GetCachedCanonValue(CanonicalFormKind kind) + private TypeDesc _specificCanonCache; + private TypeDesc _universalCanonCache; + + private TypeDesc GetCachedCanonValue(CanonicalFormKind kind) { switch (kind) { @@ -30,7 +31,7 @@ TypeDesc GetCachedCanonValue(CanonicalFormKind kind) } } - void SetCachedCanonValue(CanonicalFormKind kind, TypeDesc value) + private void SetCachedCanonValue(CanonicalFormKind kind, TypeDesc value) { switch (kind) { diff --git a/src/coreclr/tools/Common/TypeSystem/CodeGen/FieldDesc.CodeGen.cs b/src/coreclr/tools/Common/TypeSystem/CodeGen/FieldDesc.CodeGen.cs index 43f05e4d85f22..fa4f3bf017c2a 100644 --- a/src/coreclr/tools/Common/TypeSystem/CodeGen/FieldDesc.CodeGen.cs +++ b/src/coreclr/tools/Common/TypeSystem/CodeGen/FieldDesc.CodeGen.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Additional members of FieldDesc related to code generation. - partial class FieldDesc + public partial class FieldDesc { /// /// Gets a value indicating whether this is a field that needs to be treated @@ -19,7 +19,7 @@ public virtual bool IsIntrinsic } } - partial class FieldForInstantiatedType + public partial class FieldForInstantiatedType { public override bool IsIntrinsic { diff --git a/src/coreclr/tools/Common/TypeSystem/CodeGen/MethodDelegator.CodeGen.cs b/src/coreclr/tools/Common/TypeSystem/CodeGen/MethodDelegator.CodeGen.cs index 41425033e5bc6..0e1734043ddd7 100644 --- a/src/coreclr/tools/Common/TypeSystem/CodeGen/MethodDelegator.CodeGen.cs +++ b/src/coreclr/tools/Common/TypeSystem/CodeGen/MethodDelegator.CodeGen.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem { - partial class MethodDelegator + public partial class MethodDelegator { public override bool IsIntrinsic { diff --git a/src/coreclr/tools/Common/TypeSystem/CodeGen/NativeStructType.CodeGen.cs b/src/coreclr/tools/Common/TypeSystem/CodeGen/NativeStructType.CodeGen.cs index 320b8de11b09f..0e4d928673523 100644 --- a/src/coreclr/tools/Common/TypeSystem/CodeGen/NativeStructType.CodeGen.cs +++ b/src/coreclr/tools/Common/TypeSystem/CodeGen/NativeStructType.CodeGen.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem.Interop { // Implements INonEmittableType - partial class NativeStructType : INonEmittableType + public partial class NativeStructType : INonEmittableType { } } diff --git a/src/coreclr/tools/Common/TypeSystem/CodeGen/TargetDetails.CodeGen.cs b/src/coreclr/tools/Common/TypeSystem/CodeGen/TargetDetails.CodeGen.cs index f24974c811b78..353399eb78b7f 100644 --- a/src/coreclr/tools/Common/TypeSystem/CodeGen/TargetDetails.CodeGen.cs +++ b/src/coreclr/tools/Common/TypeSystem/CodeGen/TargetDetails.CodeGen.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Extension to TargetDetails related to code generation - partial class TargetDetails + public partial class TargetDetails { public TargetDetails(TargetArchitecture architecture, TargetOS targetOS, TargetAbi abi, SimdVectorLength simdVectorLength) : this(architecture, targetOS, abi) diff --git a/src/coreclr/tools/Common/TypeSystem/CodeGen/TypeDesc.CodeGen.cs b/src/coreclr/tools/Common/TypeSystem/CodeGen/TypeDesc.CodeGen.cs index eb15a3681d5a4..860285c10f234 100644 --- a/src/coreclr/tools/Common/TypeSystem/CodeGen/TypeDesc.CodeGen.cs +++ b/src/coreclr/tools/Common/TypeSystem/CodeGen/TypeDesc.CodeGen.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem { - partial class TypeDesc + public partial class TypeDesc { /// /// Gets a value indicating whether this is a type that needs to be treated @@ -18,7 +18,7 @@ public bool IsIntrinsic } } - partial class InstantiatedType + public partial class InstantiatedType { partial void AddComputedIntrinsicFlag(ref TypeFlags flags) { diff --git a/src/coreclr/tools/Common/TypeSystem/Common/ArrayOfTRuntimeInterfacesAlgorithm.cs b/src/coreclr/tools/Common/TypeSystem/Common/ArrayOfTRuntimeInterfacesAlgorithm.cs index 0e6328904c7ee..26aca2534517a 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/ArrayOfTRuntimeInterfacesAlgorithm.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/ArrayOfTRuntimeInterfacesAlgorithm.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using Debug = System.Diagnostics.Debug; namespace Internal.TypeSystem diff --git a/src/coreclr/tools/Common/TypeSystem/Common/ArrayType.cs b/src/coreclr/tools/Common/TypeSystem/Common/ArrayType.cs index c21ba9342e198..dc1fc9667faa9 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/ArrayType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/ArrayType.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using System.Threading; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/BaseTypeRuntimeInterfacesAlgorithm.cs b/src/coreclr/tools/Common/TypeSystem/Common/BaseTypeRuntimeInterfacesAlgorithm.cs index 41ff1102a8ed6..0835048af5f96 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/BaseTypeRuntimeInterfacesAlgorithm.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/BaseTypeRuntimeInterfacesAlgorithm.cs @@ -1,9 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using Debug = System.Diagnostics.Debug; - namespace Internal.TypeSystem { /// diff --git a/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.cs b/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.cs index 51ed0327c3424..d0f32078e97df 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Debug = System.Diagnostics.Debug; namespace Internal.TypeSystem @@ -535,7 +533,7 @@ private static bool IsBoxedAndCanCastTo(this TypeDesc thisType, TypeDesc otherTy return false; } - private class StackOverflowProtect + private sealed class StackOverflowProtect { private CastingPair _value; private StackOverflowProtect _previous; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/ConstructedTypeRewritingHelpers.cs b/src/coreclr/tools/Common/TypeSystem/Common/ConstructedTypeRewritingHelpers.cs index 42011765c379d..41e119bae681d 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/ConstructedTypeRewritingHelpers.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/ConstructedTypeRewritingHelpers.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Generic; using System.Diagnostics; namespace Internal.TypeSystem diff --git a/src/coreclr/tools/Common/TypeSystem/Common/DefType.Diagnostic.cs b/src/coreclr/tools/Common/TypeSystem/Common/DefType.Diagnostic.cs index 26685ff43b2f3..d1dc3c659ee32 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/DefType.Diagnostic.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/DefType.Diagnostic.cs @@ -1,15 +1,13 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Generic; - namespace Internal.TypeSystem { /// /// Type with metadata available that is equivalent to a TypeDef record in an ECMA 335 metadata stream. /// A class, an interface, or a value type. /// - abstract partial class DefType + public abstract partial class DefType { /// /// Gets the Name of a type. This must not throw diff --git a/src/coreclr/tools/Common/TypeSystem/Common/DefType.FieldLayout.cs b/src/coreclr/tools/Common/TypeSystem/Common/DefType.FieldLayout.cs index 4c3555c198af6..99305804f5351 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/DefType.FieldLayout.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/DefType.FieldLayout.cs @@ -75,7 +75,7 @@ private static class FieldLayoutFlags public const int IsInt128OrHasInt128Fields = 0x800; } - private class StaticBlockInfo + private sealed class StaticBlockInfo { public StaticsBlock NonGcStatics; public StaticsBlock GcStatics; @@ -83,17 +83,15 @@ private class StaticBlockInfo public StaticsBlock ThreadGcStatics; } - ThreadSafeFlags _fieldLayoutFlags; - - LayoutInt _instanceFieldSize; - LayoutInt _instanceFieldAlignment; - LayoutInt _instanceByteCountUnaligned; - LayoutInt _instanceByteAlignment; + private ThreadSafeFlags _fieldLayoutFlags; + private LayoutInt _instanceFieldSize; + private LayoutInt _instanceFieldAlignment; + private LayoutInt _instanceByteCountUnaligned; + private LayoutInt _instanceByteAlignment; // Information about various static blocks is rare, so we keep it out of line. - StaticBlockInfo _staticBlockInfo; - - ValueTypeShapeCharacteristics _valueTypeShapeCharacteristics; + private StaticBlockInfo _staticBlockInfo; + private ValueTypeShapeCharacteristics _valueTypeShapeCharacteristics; /// /// Does a type transitively have any fields which are GC object pointers diff --git a/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.FieldLayout.cs b/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.FieldLayout.cs index 2d8daed2caf11..e7b5e6d21478d 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.FieldLayout.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.FieldLayout.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Diagnostics; namespace Internal.TypeSystem diff --git a/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.ToString.cs b/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.ToString.cs index cde79093f286b..6d52f349f24c0 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.ToString.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.ToString.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem { - partial class FieldDesc + public partial class FieldDesc { public override string ToString() { diff --git a/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.cs index 23bd5ba923a54..a18221761429d 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Runtime.CompilerServices; using Debug = System.Diagnostics.Debug; @@ -23,8 +22,8 @@ public override int GetHashCode() public override bool Equals(object o) { // Its only valid to compare two FieldDescs in the same context - Debug.Assert(o is not FieldDesc || object.ReferenceEquals(((FieldDesc)o).Context, this.Context)); - return object.ReferenceEquals(this, o); + Debug.Assert(o is not FieldDesc || ReferenceEquals(((FieldDesc)o).Context, this.Context)); + return ReferenceEquals(this, o); } public virtual string Name diff --git a/src/coreclr/tools/Common/TypeSystem/Common/FieldForInstantiatedType.cs b/src/coreclr/tools/Common/TypeSystem/Common/FieldForInstantiatedType.cs index fbc456a830639..692e4db2a0aa9 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/FieldForInstantiatedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/FieldForInstantiatedType.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Debug = System.Diagnostics.Debug; namespace Internal.TypeSystem @@ -47,7 +45,7 @@ public override TypeDesc FieldType { get { - return _fieldDef.FieldType.InstantiateSignature(_instantiatedType.Instantiation, new Instantiation()); + return _fieldDef.FieldType.InstantiateSignature(_instantiatedType.Instantiation, default(Instantiation)); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/FunctionPointerType.cs b/src/coreclr/tools/Common/TypeSystem/Common/FunctionPointerType.cs index 1328e3c040d4d..1a0c881ca376d 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/FunctionPointerType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/FunctionPointerType.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Text; - namespace Internal.TypeSystem { /// diff --git a/src/coreclr/tools/Common/TypeSystem/Common/GenericParameterDesc.Diagnostic.cs b/src/coreclr/tools/Common/TypeSystem/Common/GenericParameterDesc.Diagnostic.cs index 7e8df4304dfd5..00f6772b608e9 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/GenericParameterDesc.Diagnostic.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/GenericParameterDesc.Diagnostic.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Generic; namespace Internal.TypeSystem { diff --git a/src/coreclr/tools/Common/TypeSystem/Common/GenericParameterDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/GenericParameterDesc.cs index a6ca019dcabdc..85f438e736412 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/GenericParameterDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/GenericParameterDesc.cs @@ -116,7 +116,7 @@ public virtual IEnumerable TypeConstraints { get { - return TypeDesc.EmptyTypes; + return EmptyTypes; } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs index 9105c566534c7..dce30dadc53d4 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs @@ -1,9 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Diagnostics; -using System.Text; using Internal.NativeFormat; namespace Internal.TypeSystem @@ -56,7 +54,7 @@ public override TypeDesc OwningType private TypeDesc Instantiate(TypeDesc type) { - return type.InstantiateSignature(new Instantiation(), _instantiation); + return type.InstantiateSignature(default(Instantiation), _instantiation); } public override MethodSignature Signature diff --git a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.Interfaces.cs b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.Interfaces.cs index 9e4cae5223470..265aef7029d4d 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.Interfaces.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.Interfaces.cs @@ -1,9 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using Debug = System.Diagnostics.Debug; - namespace Internal.TypeSystem { // Implementation for Instantiated type specific interface logic @@ -15,7 +12,7 @@ public sealed partial class InstantiatedType : MetadataType private DefType[] InitializeImplementedInterfaces() { // TODO Add duplicate detection - return (_implementedInterfaces = InstantiateTypeArray(_typeDef.ExplicitlyImplementedInterfaces, _instantiation, new Instantiation())); + return (_implementedInterfaces = InstantiateTypeArray(_typeDef.ExplicitlyImplementedInterfaces, _instantiation, default(Instantiation))); } /// diff --git a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.MethodImpls.cs b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.MethodImpls.cs index 6002edbdb23db..c8d4f91ad5d4c 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.MethodImpls.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.MethodImpls.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace Internal.TypeSystem { // Implementation of MethodImpl api surface implemented without metadata access. @@ -24,7 +22,7 @@ private MethodImplRecord[] InstantiateMethodImpls(MethodImplRecord[] uninstMetho { MethodDesc decl; - var implTypeInstantiated = uninstMethodImpls[i].Decl.OwningType.InstantiateSignature(this.Instantiation, new Instantiation()); + var implTypeInstantiated = uninstMethodImpls[i].Decl.OwningType.InstantiateSignature(this.Instantiation, default(Instantiation)); if (implTypeInstantiated is InstantiatedType) { decl = _typeDef.Context.GetMethodForInstantiatedType(uninstMethodImpls[i].Decl.GetTypicalMethodDefinition(), (InstantiatedType)implTypeInstantiated); diff --git a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs index bed4e2388e92a..2b9e2774324ba 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs @@ -1,9 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; -using System.Text; using System.Diagnostics; namespace Internal.TypeSystem @@ -55,7 +53,7 @@ private MetadataType InitializeBaseType() { var uninst = _typeDef.MetadataBaseType; - return (_baseType = (uninst != null) ? (MetadataType)uninst.InstantiateSignature(_instantiation, new Instantiation()) : null); + return (_baseType = (uninst != null) ? (MetadataType)uninst.InstantiateSignature(_instantiation, default(Instantiation)) : null); } public override DefType BaseType diff --git a/src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs b/src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs index c794377bf1971..8eefeb20bb080 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs @@ -26,7 +26,7 @@ public LayoutInt(int input) { if (input < 0) { - throw new ArgumentException(); + throw default(ArgumentException); } else { diff --git a/src/coreclr/tools/Common/TypeSystem/Common/LinqPoison.cs b/src/coreclr/tools/Common/TypeSystem/Common/LinqPoison.cs index ce2675fa2b1dc..2473b14397cab 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/LinqPoison.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/LinqPoison.cs @@ -16,5 +16,5 @@ namespace System // "using System.Linq" from your file. Do not modify this file or // remove it from the project. // - internal class Linq { } + internal sealed class Linq { } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MetadataFieldLayoutAlgorithm.cs b/src/coreclr/tools/Common/TypeSystem/Common/MetadataFieldLayoutAlgorithm.cs index 5ff6417e52e41..62d40846951fb 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MetadataFieldLayoutAlgorithm.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MetadataFieldLayoutAlgorithm.cs @@ -53,7 +53,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp } // Global types do not do the rest of instance field layout. - ComputedInstanceFieldLayout result = new ComputedInstanceFieldLayout(); + ComputedInstanceFieldLayout result = default(ComputedInstanceFieldLayout); result.Offsets = Array.Empty(); return result; } @@ -180,10 +180,10 @@ public override ComputedStaticFieldLayout ComputeStaticFieldLayout(DefType defTy } ComputedStaticFieldLayout result; - result.GcStatics = new StaticsBlock(); - result.NonGcStatics = new StaticsBlock(); - result.ThreadGcStatics = new StaticsBlock(); - result.ThreadNonGcStatics = new StaticsBlock(); + result.GcStatics = default(StaticsBlock); + result.NonGcStatics = default(StaticsBlock); + result.ThreadGcStatics = default(StaticsBlock); + result.ThreadNonGcStatics = default(StaticsBlock); if (numStaticFields == 0) { @@ -216,7 +216,7 @@ public override ComputedStaticFieldLayout ComputeStaticFieldLayout(DefType defTy block.Size = LayoutInt.AlignUp(block.Size, sizeAndAlignment.Alignment, context.Target); result.Offsets[index] = new FieldAndOffset(field, block.Size); - block.Size = block.Size + sizeAndAlignment.Size; + block.Size += sizeAndAlignment.Size; block.LargestAlignment = LayoutInt.Max(block.LargestAlignment, sizeAndAlignment.Alignment); @@ -228,7 +228,7 @@ public override ComputedStaticFieldLayout ComputeStaticFieldLayout(DefType defTy return result; } - private ref StaticsBlock GetStaticsBlockForField(ref ComputedStaticFieldLayout layout, FieldDesc field) + private static ref StaticsBlock GetStaticsBlockForField(ref ComputedStaticFieldLayout layout, FieldDesc field) { if (field.IsThreadStatic) { @@ -453,7 +453,6 @@ protected ComputedInstanceFieldLayout ComputeAutoFieldLayout(MetadataType type, TypeSystemContext context = type.Context; bool hasLayout = type.HasLayout(); - var layoutMetadata = type.GetClassLayout(); // Auto-layout in CoreCLR does not respect packing size. int packingSize = type.Context.Target.MaximumAlignment; @@ -793,7 +792,7 @@ private static int CalculateLog2(int size) int log2size; for (log2size = 0; size > 1; log2size++) { - size = size >> 1; + size >>= 1; } return log2size; @@ -945,7 +944,7 @@ public override ValueTypeShapeCharacteristics ComputeValueTypeShapeCharacteristi return ComputeHomogeneousAggregateCharacteristic(type); } - private ValueTypeShapeCharacteristics ComputeHomogeneousAggregateCharacteristic(DefType type) + private static ValueTypeShapeCharacteristics ComputeHomogeneousAggregateCharacteristic(DefType type) { // Use this constant to make the code below more laconic const ValueTypeShapeCharacteristics NotHA = ValueTypeShapeCharacteristics.None; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MetadataRuntimeInterfacesAlgorithm.cs b/src/coreclr/tools/Common/TypeSystem/Common/MetadataRuntimeInterfacesAlgorithm.cs index 02b94121e52e0..fa3f125019860 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MetadataRuntimeInterfacesAlgorithm.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MetadataRuntimeInterfacesAlgorithm.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using Debug = System.Diagnostics.Debug; namespace Internal.TypeSystem { @@ -37,13 +36,11 @@ public override DefType[] ComputeRuntimeInterfaces(TypeDesc _type) /// so the algorithm works by computing the uninstantiated form, and then /// specializing each interface as needed. /// - private DefType[] ComputeRuntimeInterfacesForInstantiatedType(InstantiatedType instantiatedType) + private static DefType[] ComputeRuntimeInterfacesForInstantiatedType(InstantiatedType instantiatedType) { MetadataType uninstantiatedType = (MetadataType)instantiatedType.GetTypeDefinition(); - DefType[] genericTypeDefinitionInterfaces = uninstantiatedType.RuntimeInterfaces; - - return InstantiatedType.InstantiateTypeArray(uninstantiatedType.RuntimeInterfaces, instantiatedType.Instantiation, new Instantiation()); + return InstantiatedType.InstantiateTypeArray(uninstantiatedType.RuntimeInterfaces, instantiatedType.Instantiation, default(Instantiation)); } /// @@ -58,7 +55,7 @@ private DefType[] ComputeRuntimeInterfacesForNonInstantiatedMetadataType(Metadat if (explicitInterfaces.Length == 0) return baseTypeInterfaces; - ArrayBuilder interfacesArray = new ArrayBuilder(); + ArrayBuilder interfacesArray = default(ArrayBuilder); interfacesArray.Append(baseTypeInterfaces); foreach (DefType iface in explicitInterfaces) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MetadataType.Interfaces.cs b/src/coreclr/tools/Common/TypeSystem/Common/MetadataType.Interfaces.cs index 011a16b301a0b..3744352723f37 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MetadataType.Interfaces.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MetadataType.Interfaces.cs @@ -1,9 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using Debug = System.Diagnostics.Debug; - namespace Internal.TypeSystem { // Api surface definition for interfaces that all MetadataTypes must implement diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MetadataType.MethodImpls.cs b/src/coreclr/tools/Common/TypeSystem/Common/MetadataType.MethodImpls.cs index faea42eea60ea..17871fee71751 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MetadataType.MethodImpls.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MetadataType.MethodImpls.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace Internal.TypeSystem { public struct MethodImplRecord diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MetadataTypeSystemContext.cs b/src/coreclr/tools/Common/TypeSystem/Common/MetadataTypeSystemContext.cs index 97b6e62acb592..2e04cfb85c8ed 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MetadataTypeSystemContext.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MetadataTypeSystemContext.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using Debug = System.Diagnostics.Debug; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs b/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs index b3ef2048747b8..8b0112184f92c 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs @@ -9,7 +9,7 @@ namespace Internal.TypeSystem { public class MetadataVirtualMethodAlgorithm : VirtualMethodAlgorithm { - private class MethodDescHashtable : LockFreeReaderHashtable + private sealed class MethodDescHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(MethodDesc key) { @@ -24,13 +24,13 @@ protected override int GetValueHashCode(MethodDesc value) protected override bool CompareKeyToValue(MethodDesc key, MethodDesc value) { Debug.Assert(key.Context == value.Context); - return object.ReferenceEquals(key, value); + return ReferenceEquals(key, value); } protected override bool CompareValueToValue(MethodDesc value1, MethodDesc value2) { Debug.Assert(value1.Context == value2.Context); - return object.ReferenceEquals(value1, value2); + return ReferenceEquals(value1, value2); } protected override MethodDesc CreateValueFromKey(MethodDesc key) @@ -39,7 +39,7 @@ protected override MethodDesc CreateValueFromKey(MethodDesc key) } } - private class UnificationGroup + private sealed class UnificationGroup { private MethodDesc[] _members = MethodDesc.EmptyMethods; private int _memberCount; @@ -467,8 +467,7 @@ private static void FindBaseUnificationGroup(MetadataType currentType, Unificati MethodDesc nameSigMatchMemberMethod = FindMatchingVirtualMethodOnTypeByNameAndSigWithSlotCheck(memberMethod, currentType, reverseMethodSearch: true); if (nameSigMatchMemberMethod != null && nameSigMatchMemberMethod != memberMethod) { - if (separatedMethods == null) - separatedMethods = new MethodDescHashtable(); + separatedMethods ??= new MethodDescHashtable(); separatedMethods.AddOrGetExisting(memberMethod); } } @@ -491,8 +490,7 @@ private static void FindBaseUnificationGroup(MetadataType currentType, Unificati { unificationGroup.RemoveFromGroup(declSlot); - if (separatedMethods == null) - separatedMethods = new MethodDescHashtable(); + separatedMethods ??= new MethodDescHashtable(); separatedMethods.AddOrGetExisting(declSlot); if (unificationGroup.RequiresSlotUnification(declSlot) || implSlot.RequiresSlotUnification()) @@ -907,8 +905,6 @@ public static IEnumerable EnumAllVirtualSlots(MetadataType type) /// MethodDesc of the resolved virtual static method, null when not found (runtime lookup must be used) public static MethodDesc ResolveInterfaceMethodToStaticVirtualMethodOnType(MethodDesc interfaceMethod, MetadataType currentType) { - TypeDesc interfaceType = interfaceMethod.OwningType; - // Search for match on a per-level in the type hierarchy for (MetadataType typeToCheck = currentType; typeToCheck != null; typeToCheck = typeToCheck.MetadataBaseType) { diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodDelegator.Diagnostic.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodDelegator.Diagnostic.cs index 4290daf473654..dd1f7c6442fe3 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodDelegator.Diagnostic.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodDelegator.Diagnostic.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem { - partial class MethodDelegator + public partial class MethodDelegator { public override string DiagnosticName => _wrappedMethod.DiagnosticName; } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.Diagnostic.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.Diagnostic.cs index 99784da0a3478..f86297f1a2a20 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.Diagnostic.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.Diagnostic.cs @@ -1,11 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Text; - namespace Internal.TypeSystem { - partial class MethodDesc + public partial class MethodDesc { public abstract string DiagnosticName { get; } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.ToString.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.ToString.cs index 485f28c809f48..e53daaab2d1ac 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.ToString.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.ToString.cs @@ -5,7 +5,7 @@ namespace Internal.TypeSystem { - partial class MethodSignature + public partial class MethodSignature { public override string ToString() { @@ -39,7 +39,7 @@ public string ToString(bool includeReturnType) } } - partial class MethodDesc + public partial class MethodDesc { public override string ToString() { diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs index f2abb6fedfa5d..33af7a32f68b4 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs @@ -60,7 +60,7 @@ public static string GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(int } // Provide a means to create a MethodSignature which ignores EmbeddedSignature data in the MethodSignatures it is compared to - public static EmbeddedSignatureData[] EmbeddedSignatureMismatchPermittedFlag = new EmbeddedSignatureData[0]; + public static EmbeddedSignatureData[] EmbeddedSignatureMismatchPermittedFlag = Array.Empty(); public MethodSignature(MethodSignatureFlags flags, int genericParameterCount, TypeDesc returnType, TypeDesc[] parameters, EmbeddedSignatureData[] embeddedSignatureData = null) { @@ -445,8 +445,8 @@ protected virtual int ComputeHashCode() public override bool Equals(object o) { // Its only valid to compare two MethodDescs in the same context - Debug.Assert(o is not MethodDesc || object.ReferenceEquals(((MethodDesc)o).Context, this.Context)); - return object.ReferenceEquals(this, o); + Debug.Assert(o is not MethodDesc || ReferenceEquals(((MethodDesc)o).Context, this.Context)); + return ReferenceEquals(this, o); } /// diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs index 1691d5624ae38..30c3fe8a1e188 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Debug = System.Diagnostics.Debug; namespace Internal.TypeSystem @@ -48,7 +46,7 @@ public override TypeDesc OwningType private TypeDesc Instantiate(TypeDesc type) { - return type.InstantiateSignature(_instantiatedType.Instantiation, new Instantiation()); + return type.InstantiateSignature(_instantiatedType.Instantiation, default(Instantiation)); } public override MethodSignature Signature diff --git a/src/coreclr/tools/Common/TypeSystem/Common/ModuleDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/ModuleDesc.cs index 9a7ac0a97c856..87fa16a581944 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/ModuleDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/ModuleDesc.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; namespace Internal.TypeSystem diff --git a/src/coreclr/tools/Common/TypeSystem/Common/ParameterizedType.cs b/src/coreclr/tools/Common/TypeSystem/Common/ParameterizedType.cs index 6ec0fbd352bff..ba0f5720c0335 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/ParameterizedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/ParameterizedType.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace Internal.TypeSystem { public abstract partial class ParameterizedType : TypeDesc diff --git a/src/coreclr/tools/Common/TypeSystem/Common/SignatureVariable.cs b/src/coreclr/tools/Common/TypeSystem/Common/SignatureVariable.cs index 0bfcf24dc7c53..4a26cb619d57b 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/SignatureVariable.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/SignatureVariable.cs @@ -1,12 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.NativeFormat; -using Debug = System.Diagnostics.Debug; - namespace Internal.TypeSystem { public abstract partial class SignatureVariable : TypeDesc diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TargetArchitecture.cs b/src/coreclr/tools/Common/TypeSystem/Common/TargetArchitecture.cs index 160ff674f8d71..928e3018b0672 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TargetArchitecture.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TargetArchitecture.cs @@ -1,9 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using Debug = System.Diagnostics.Debug; - namespace Internal.TypeSystem { /// diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TargetDetails.ToString.cs b/src/coreclr/tools/Common/TypeSystem/Common/TargetDetails.ToString.cs index 413f789853edd..37a065260d08a 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TargetDetails.ToString.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TargetDetails.ToString.cs @@ -1,12 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using Debug = System.Diagnostics.Debug; - namespace Internal.TypeSystem { - partial class TargetDetails + public partial class TargetDetails { public override string ToString() { diff --git a/src/coreclr/tools/Common/TypeSystem/Common/ThrowHelper.Common.cs b/src/coreclr/tools/Common/TypeSystem/Common/ThrowHelper.Common.cs index cf644ad14d4c9..58114db36dfc8 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/ThrowHelper.Common.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/ThrowHelper.Common.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Text; using Debug = System.Diagnostics.Debug; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.Interfaces.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.Interfaces.cs index ce778fa590e79..5d4349ec6c14d 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.Interfaces.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.Interfaces.cs @@ -3,7 +3,6 @@ using System; using System.Threading; -using Debug = System.Diagnostics.Debug; namespace Internal.TypeSystem { diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.ToString.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.ToString.cs index 4b63e28d4303e..4995be92c5454 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.ToString.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.ToString.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem { - partial class TypeDesc + public partial class TypeDesc { public override string ToString() { diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs index 905a9bbca5b2b..b85c803cec078 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs @@ -24,23 +24,23 @@ public abstract partial class TypeDesc : TypeSystemEntity public override bool Equals(object o) { // Its only valid to compare two TypeDescs in the same context - Debug.Assert(o is not TypeDesc || object.ReferenceEquals(((TypeDesc)o).Context, this.Context)); - return object.ReferenceEquals(this, o); + Debug.Assert(o is not TypeDesc || ReferenceEquals(((TypeDesc)o).Context, this.Context)); + return ReferenceEquals(this, o); } #if DEBUG public static bool operator ==(TypeDesc left, TypeDesc right) { // Its only valid to compare two TypeDescs in the same context - Debug.Assert(left is null || right is null || object.ReferenceEquals(left.Context, right.Context)); - return object.ReferenceEquals(left, right); + Debug.Assert(left is null || right is null || ReferenceEquals(left.Context, right.Context)); + return ReferenceEquals(left, right); } public static bool operator !=(TypeDesc left, TypeDesc right) { // Its only valid to compare two TypeDescs in the same context - Debug.Assert(left is null || right is null || object.ReferenceEquals(left.Context, right.Context)); - return !object.ReferenceEquals(left, right); + Debug.Assert(left is null || right is null || ReferenceEquals(left.Context, right.Context)); + return !ReferenceEquals(left, right); } #endif diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeHashingAlgorithms.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeHashingAlgorithms.cs index 5904397c4a015..1b9692037fe94 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeHashingAlgorithms.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeHashingAlgorithms.cs @@ -5,7 +5,6 @@ // Generic functions to compute the hashcode value of types // --------------------------------------------------------------------------- -using System; using System.Diagnostics; using System.Runtime.CompilerServices; using System.Text; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemConstraintsHelpers.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemConstraintsHelpers.cs index d749946a72a3d..acd8e291cebd4 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemConstraintsHelpers.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemConstraintsHelpers.cs @@ -53,7 +53,7 @@ private static bool VerifyGenericParamConstraint(InstantiationContext genericPar if (instantiationParam.IsByRefLike && (constraints & GenericConstraints.AcceptByRefLike) == 0) return false; - var instantiatedConstraints = new ArrayBuilder(); + var instantiatedConstraints = default(ArrayBuilder); GetInstantiatedConstraintsRecursive(instantiationParamContext, instantiationParam, ref instantiatedConstraints); foreach (var constraintType in genericParam.TypeConstraints) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemContext.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemContext.cs index fcb47f42d3c92..af5beb8a73875 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemContext.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemContext.cs @@ -117,7 +117,7 @@ public int Rank } } - public class ArrayTypeKeyHashtable : LockFreeReaderHashtable + public sealed class ArrayTypeKeyHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(ArrayTypeKey key) { @@ -304,7 +304,7 @@ public Instantiation Instantiation } } - public class InstantiatedTypeKeyHashtable : LockFreeReaderHashtable + public sealed class InstantiatedTypeKeyHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(InstantiatedTypeKey key) { @@ -403,7 +403,7 @@ public Instantiation Instantiation } } - public class InstantiatedMethodKeyHashtable : LockFreeReaderHashtable + public sealed class InstantiatedMethodKeyHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(InstantiatedMethodKey key) { @@ -502,7 +502,7 @@ public InstantiatedType InstantiatedType } } - public class MethodForInstantiatedTypeKeyHashtable : LockFreeReaderHashtable + public sealed class MethodForInstantiatedTypeKeyHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(MethodForInstantiatedTypeKey key) { @@ -575,7 +575,7 @@ public InstantiatedType InstantiatedType } } - public class FieldForInstantiatedTypeKeyHashtable : LockFreeReaderHashtable + public sealed class FieldForInstantiatedTypeKeyHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(FieldForInstantiatedTypeKey key) { @@ -617,7 +617,7 @@ public FieldDesc GetFieldForInstantiatedType(FieldDesc fieldDef, InstantiatedTyp // // Signature variables // - private class SignatureVariableHashtable : LockFreeReaderHashtable + private sealed class SignatureVariableHashtable : LockFreeReaderHashtable { private TypeSystemContext _context; public SignatureVariableHashtable(TypeSystemContext context) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemException.Resources.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemException.Resources.cs index bf5a3b97b292f..056c0aa6e5a6b 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemException.Resources.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemException.Resources.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Generic; using System.Globalization; using System.Resources; using System.Reflection; @@ -11,7 +10,7 @@ // need to support accessing these strings via the ResourceManager namespace Internal.TypeSystem { - partial class TypeSystemException : Exception + public partial class TypeSystemException : Exception { private static Lazy s_stringResourceManager = new Lazy(() => new ResourceManager("Internal.TypeSystem.Strings", typeof(TypeSystemException).GetTypeInfo().Assembly)); diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemException.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemException.cs index 39015e807d94c..6c8cd66654af3 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemException.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemException.cs @@ -50,12 +50,12 @@ private static string GetExceptionString(ExceptionStringID id, string[] args) { if (formatString != null) { - return String.Format(formatString, (object[])args); + return string.Format(formatString, (object[])args); } } catch {} - - return "[TEMPORARY EXCEPTION MESSAGE] " + id.ToString() + ": " + String.Join(", ", args); + + return "[TEMPORARY EXCEPTION MESSAGE] " + id.ToString() + ": " + string.Join(", ", args); } /// diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs index 7c841444f15b0..b139b1b1e6b58 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs @@ -363,7 +363,7 @@ public static bool ContainsSignatureVariables(this TypeDesc thisType, bool treat // It is generally a bug to have instantiations over generic parameters // in the system. Typical instantiations are represented as instantiations // over own formals - so these should be signature variables instead. - throw new ArgumentException(); + throw default(ArgumentException); default: Debug.Assert(thisType is DefType); diff --git a/src/coreclr/tools/Common/TypeSystem/Common/UniversalCanonLayoutAlgorithm.cs b/src/coreclr/tools/Common/TypeSystem/Common/UniversalCanonLayoutAlgorithm.cs index 196aef8c7e41c..36987f950946f 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/UniversalCanonLayoutAlgorithm.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/UniversalCanonLayoutAlgorithm.cs @@ -3,10 +3,6 @@ using System; -using Internal.NativeFormat; - -using Debug = System.Diagnostics.Debug; - namespace Internal.TypeSystem { public class UniversalCanonLayoutAlgorithm : FieldLayoutAlgorithm diff --git a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameFormatter.cs b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameFormatter.cs index 94a9caa2ad1ff..67ee949b83540 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameFormatter.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameFormatter.cs @@ -165,7 +165,7 @@ protected override IAssemblyDesc AppendNameForNestedType(StringBuilder sb, DefTy } private static char[] s_escapedChars = new char[] { ',', '=', '"', ']', '[', '*', '&', '+', '\\' }; - private void AppendEscapedIdentifier(StringBuilder sb, string identifier) + private static void AppendEscapedIdentifier(StringBuilder sb, string identifier) { if (identifier.IndexOfAny(s_escapedChars) < 0) { diff --git a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameParser.cs b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameParser.cs index 1b901f5e623ed..61eca5be798c4 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameParser.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameParser.cs @@ -78,7 +78,7 @@ public static TypeDesc GetTypeByCustomAttributeTypeName(this ModuleDesc module, if (typeDef == null) return null; - ArrayBuilder genericArgs = new ArrayBuilder(); + ArrayBuilder genericArgs = default(ArrayBuilder); // Followed by generic instantiation parameters (but check for the array case) if (ch < nameEnd && ch.Current == '[' && (ch + 1) < nameEnd && (ch + 1).Current != ']' && (ch + 1).Current != ',') @@ -184,7 +184,9 @@ public static TypeDesc GetTypeByCustomAttributeTypeName(this ModuleDesc module, if (ch.Current == '&') { loadedType = loadedType.MakeByRefType(); +#pragma warning disable IDE0059 // Unnecessary assignment of a value ch++; +#pragma warning restore IDE0059 // Unnecessary assignment of a value } } @@ -232,7 +234,7 @@ public static MetadataType ResolveCustomAttributeTypeDefinitionName(string name, { if (throwIfNotFound) ThrowHelper.ThrowTypeLoadException(typeName.ToString(), outerType.Module); - + return null; } } @@ -374,7 +376,9 @@ private static StringIterator End(this string s) return new StringIterator(s, s.Length); } - struct StringIterator +#pragma warning disable CA1066 // Implement IEquatable when overriding Object.Equals + private struct StringIterator +#pragma warning restore CA1066 // Implement IEquatable when overriding Object.Equals { private string _string; private int _index; @@ -396,46 +400,46 @@ public StringIterator(string s, int index) public static string Substring(StringIterator it1, StringIterator it2) { - Debug.Assert(Object.ReferenceEquals(it1._string, it2._string)); + Debug.Assert(ReferenceEquals(it1._string, it2._string)); return it1._string.Substring(it1._index, it2._index - it1._index); } - public static StringIterator operator++(StringIterator it) + public static StringIterator operator ++(StringIterator it) { return new StringIterator(it._string, ++it._index); } public static bool operator <(StringIterator it1, StringIterator it2) { - Debug.Assert(Object.ReferenceEquals(it1._string, it2._string)); + Debug.Assert(ReferenceEquals(it1._string, it2._string)); return it1._index < it2._index; } public static bool operator >(StringIterator it1, StringIterator it2) { - Debug.Assert(Object.ReferenceEquals(it1._string, it2._string)); + Debug.Assert(ReferenceEquals(it1._string, it2._string)); return it1._index > it2._index; } - public static StringIterator operator+(StringIterator it, int val) + public static StringIterator operator +(StringIterator it, int val) { return new StringIterator(it._string, it._index + val); } - public static StringIterator operator-(StringIterator it, int val) + public static StringIterator operator -(StringIterator it, int val) { return new StringIterator(it._string, it._index - val); } - public static bool operator==(StringIterator it1, StringIterator it2) + public static bool operator ==(StringIterator it1, StringIterator it2) { - Debug.Assert(Object.ReferenceEquals(it1._string, it2._string)); + Debug.Assert(ReferenceEquals(it1._string, it2._string)); return it1._index == it2._index; } public static bool operator !=(StringIterator it1, StringIterator it2) { - Debug.Assert(Object.ReferenceEquals(it1._string, it2._string)); + Debug.Assert(ReferenceEquals(it1._string, it2._string)); return it1._index != it2._index; } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/DebugNameFormatter.cs b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/DebugNameFormatter.cs index 607287e45f6dc..8c6c3a00fa7cb 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/DebugNameFormatter.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/DebugNameFormatter.cs @@ -4,8 +4,6 @@ using System; using System.Text; -using Debug = System.Diagnostics.Debug; - namespace Internal.TypeSystem { public partial class DebugNameFormatter : TypeNameFormatter diff --git a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/ExceptionTypeNameFormatter.Metadata.cs b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/ExceptionTypeNameFormatter.Metadata.cs index 92d3319a0c15f..79a6da8f59a45 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/ExceptionTypeNameFormatter.Metadata.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/ExceptionTypeNameFormatter.Metadata.cs @@ -4,14 +4,14 @@ namespace Internal.TypeSystem { // Type name formatting functionality that relies on metadata. - partial class ExceptionTypeNameFormatter + public partial class ExceptionTypeNameFormatter { - private string GetTypeName(DefType type) + private static string GetTypeName(DefType type) { return type.Name; } - private string GetTypeNamespace(DefType type) + private static string GetTypeNamespace(DefType type) { return type.Namespace; } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/GCPointerMap.Algorithm.cs b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/GCPointerMap.Algorithm.cs index b4fc577fb7bb6..eca01c4b3a458 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/GCPointerMap.Algorithm.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/GCPointerMap.Algorithm.cs @@ -5,7 +5,7 @@ namespace Internal.TypeSystem { - partial struct GCPointerMap + public partial struct GCPointerMap { /// /// Computes the GC pointer map for the instance fields of . diff --git a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/GCPointerMap.cs b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/GCPointerMap.cs index 7f2d2195f3c8b..0e2bacf49bfe8 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/GCPointerMap.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/GCPointerMap.cs @@ -129,7 +129,7 @@ public override string ToString() sb.Append(bit ? '1' : '0'); return sb.ToString(); } - + public int CompareTo(GCPointerMap other) { if (_numCells != other._numCells) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/LockFreeReaderHashtable.cs b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/LockFreeReaderHashtable.cs index 77e777d3c0d50..8a298ffb4a981 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/LockFreeReaderHashtable.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/LockFreeReaderHashtable.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Threading; -using System.Threading.Tasks; using Debug = System.Diagnostics.Debug; namespace Internal.TypeSystem @@ -245,7 +244,7 @@ private TValue WaitForSentinelInHashtableToDisappear(TValue[] hashtable, int tab if (sentinel == null) return null; - var sw = new SpinWait(); + var sw = default(SpinWait); while (true) { TValue value = Volatile.Read(ref hashtable[tableIndex]); @@ -594,7 +593,9 @@ public bool Contains(TKey key) public TValue GetValueIfExists(TValue value) { if (value == null) +#pragma warning disable CA2208 // Instantiate argument exceptions correctly throw new ArgumentNullException(); +#pragma warning restore CA2208 // Instantiate argument exceptions correctly TValue[] hashTableLocal = GetCurrentHashtable(); Debug.Assert(hashTableLocal.Length > 0); diff --git a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/TypeNameFormatter.cs b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/TypeNameFormatter.cs index 11ad86d7874e7..4dc7e6020d973 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/TypeNameFormatter.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/TypeNameFormatter.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Text; using Debug = System.Diagnostics.Debug; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/WellKnownType.cs b/src/coreclr/tools/Common/TypeSystem/Common/WellKnownType.cs index b16257f21697e..c726b3f719f38 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/WellKnownType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/WellKnownType.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace Internal.TypeSystem { // The following enum is required for interop with the VS Debugger diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/CachingMetadataStringDecoder.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/CachingMetadataStringDecoder.cs index 7a1ccfadb8bc1..cd0e77453ccdc 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/CachingMetadataStringDecoder.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/CachingMetadataStringDecoder.cs @@ -1,9 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Reflection.Metadata; -using System.Runtime.CompilerServices; using Debug = System.Diagnostics.Debug; using Internal.NativeFormat; @@ -173,7 +171,7 @@ public string Lookup(string s) return Add(hashCode, s); } - public unsafe override string GetString(byte* bytes, int byteCount) + public override unsafe string GetString(byte* bytes, int byteCount) { bool isAscii; int hashCode = TypeHashingAlgorithms.ComputeASCIINameHashCode(bytes, byteCount, out isAscii); diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaAssembly.Symbols.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaAssembly.Symbols.cs index 0ca7305763cae..90ad54f4456e6 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaAssembly.Symbols.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaAssembly.Symbols.cs @@ -7,7 +7,7 @@ namespace Internal.TypeSystem.Ecma { // Pluggable file that adds PDB handling functionality to EcmaAssembly - partial class EcmaAssembly + public partial class EcmaAssembly { internal EcmaAssembly(TypeSystemContext context, PEReader peReader, MetadataReader metadataReader, PdbSymbolReader pdbReader, IModuleResolver customModuleResolver) : base(context, peReader, metadataReader, containingAssembly: null, pdbReader, customModuleResolver) diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.CodeGen.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.CodeGen.cs index 2f76289e4ab2e..963ee08762c27 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.CodeGen.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.CodeGen.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem.Ecma { - partial class EcmaField + public partial class EcmaField { public override bool IsIntrinsic { diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.Serialization.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.Serialization.cs index 52a7a474dbf00..f2767d459156d 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.Serialization.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.Serialization.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem.Ecma { - partial class EcmaField + public partial class EcmaField { public override bool IsNotSerialized { diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.Sorting.cs index 9151b571936b7..5b3dd3200f1ba 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.Sorting.cs @@ -6,7 +6,7 @@ namespace Internal.TypeSystem.Ecma { // Functionality related to deterministic ordering of types and members - partial class EcmaField + public partial class EcmaField { protected internal override int ClassCode => 44626835; diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.Sorting.cs index cc74c3ba5e6c4..730abcce7f0b7 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.Sorting.cs @@ -6,7 +6,7 @@ namespace Internal.TypeSystem.Ecma { // Functionality related to deterministic ordering of types - partial class EcmaGenericParameter + public partial class EcmaGenericParameter { protected internal override int ClassCode => -1548417824; diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.cs index 7451c0a9fb432..0ecf1c409be81 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.cs @@ -1,10 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using System.Reflection.Metadata; -using Internal.NativeFormat; using Debug = System.Diagnostics.Debug; using GenericParameterAttributes = System.Reflection.GenericParameterAttributes; @@ -108,7 +106,7 @@ public override GenericConstraints Constraints return (GenericConstraints)(parameter.Attributes & GenericParameterAttributes.SpecialConstraintMask); } } - + public override IEnumerable TypeConstraints { get @@ -119,7 +117,7 @@ public override IEnumerable TypeConstraints GenericParameterConstraintHandleCollection constraintHandles = parameter.GetConstraints(); if (constraintHandles.Count == 0) - return TypeDesc.EmptyTypes; + return EmptyTypes; TypeDesc[] constraintTypes = new TypeDesc[constraintHandles.Count]; diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.Sorting.cs index 09ea200aa065a..3ad587d76bb6a 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.Sorting.cs @@ -6,7 +6,7 @@ namespace Internal.TypeSystem.Ecma { // Functionality related to deterministic ordering of types - partial class EcmaMethod + public partial class EcmaMethod { protected internal override int ClassCode => 1419431046; diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs index 182a87c56765f..63eb97c3726f2 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs @@ -362,7 +362,7 @@ public override bool IsDefaultConstructor get { MethodAttributes attributes = Attributes; - return attributes.IsRuntimeSpecialName() + return attributes.IsRuntimeSpecialName() && attributes.IsPublic() && Signature.Length == 0 && Name == ".ctor" @@ -546,7 +546,7 @@ private MethodImportAttributes GetImportAttributesFromBestFitMappingAttribute(Cu public override ParameterMetadata[] GetParameterMetadata() { MetadataReader metadataReader = MetadataReader; - + // Spot check the enums match Debug.Assert((int)ParameterAttributes.In == (int)ParameterMetadataAttributes.In); Debug.Assert((int)ParameterAttributes.Out == (int)ParameterMetadataAttributes.Out); diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.Sorting.cs index a86c4f030d539..86ec596890738 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.Sorting.cs @@ -7,7 +7,7 @@ namespace Internal.TypeSystem.Ecma { - partial class EcmaModule + public partial class EcmaModule { public int CompareTo(EcmaModule other) { diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.Symbols.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.Symbols.cs index 821f8643ea349..30d0d180b9ec7 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.Symbols.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.Symbols.cs @@ -7,7 +7,7 @@ namespace Internal.TypeSystem.Ecma { // Pluggable file that adds PDB handling functionality to EcmaModule - partial class EcmaModule + public partial class EcmaModule { public PdbSymbolReader PdbReader { diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs index 35634b46d1e69..7140a8b0333fc 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs @@ -51,7 +51,7 @@ public object Object } } - internal class EcmaObjectLookupHashtable : LockFreeReaderHashtable + internal sealed class EcmaObjectLookupHashtable : LockFreeReaderHashtable { private EcmaModule _module; @@ -77,7 +77,7 @@ protected override bool CompareKeyToValue(EntityHandle key, IEntityHandleObject protected override bool CompareValueToValue(IEntityHandleObject value1, IEntityHandleObject value2) { - if (Object.ReferenceEquals(value1, value2)) + if (ReferenceEquals(value1, value2)) return true; else return value1.Handle.Equals(value2.Handle); @@ -177,7 +177,7 @@ private object ResolveModuleReference(ModuleReferenceHandle handle) } private LockFreeReaderHashtable _resolvedTokens; - IModuleResolver _moduleResolver; + private IModuleResolver _moduleResolver; internal EcmaModule(TypeSystemContext context, PEReader peReader, MetadataReader metadataReader, IAssemblyDesc containingAssembly, IModuleResolver customModuleResolver) : base(context, containingAssembly) @@ -185,7 +185,7 @@ internal EcmaModule(TypeSystemContext context, PEReader peReader, MetadataReader _peReader = peReader; _metadataReader = metadataReader; _resolvedTokens = new EcmaObjectLookupHashtable(this); - _moduleResolver = customModuleResolver != null ? customModuleResolver : context; + _moduleResolver = customModuleResolver ?? context; } public static EcmaModule Create(TypeSystemContext context, PEReader peReader, IAssemblyDesc containingAssembly, IModuleResolver customModuleResolver = null) @@ -208,7 +208,7 @@ private static MetadataReader CreateMetadataReader(TypeSystemContext context, PE var stringDecoderProvider = context as IMetadataStringDecoderProvider; MetadataReader metadataReader = peReader.GetMetadataReader(MetadataReaderOptions.None /* MetadataReaderOptions.ApplyWindowsRuntimeProjections */, - (stringDecoderProvider != null) ? stringDecoderProvider.GetMetadataStringDecoder() : null); + stringDecoderProvider?.GetMetadataStringDecoder()); return metadataReader; } @@ -353,7 +353,7 @@ public TypeDesc GetType(EntityHandle handle) { TypeDesc type = GetObject(handle, NotFoundBehavior.Throw) as TypeDesc; if (type == null) - ThrowHelper.ThrowBadImageFormatException($"type expected for handle {handle.ToString()}"); + ThrowHelper.ThrowBadImageFormatException($"type expected for handle {handle}"); return type; } @@ -361,7 +361,7 @@ public MethodDesc GetMethod(EntityHandle handle) { MethodDesc method = GetObject(handle, NotFoundBehavior.Throw) as MethodDesc; if (method == null) - ThrowHelper.ThrowBadImageFormatException($"method expected for handle {handle.ToString()}"); + ThrowHelper.ThrowBadImageFormatException($"method expected for handle {handle}"); return method; } @@ -369,11 +369,11 @@ public FieldDesc GetField(EntityHandle handle) { FieldDesc field = GetObject(handle, NotFoundBehavior.Throw) as FieldDesc; if (field == null) - ThrowHelper.ThrowBadImageFormatException($"field expected for handle {handle.ToString()}"); + ThrowHelper.ThrowBadImageFormatException($"field expected for handle {handle}"); return field; } - public Object GetObject(EntityHandle handle, NotFoundBehavior notFoundBehavior = NotFoundBehavior.Throw) + public object GetObject(EntityHandle handle, NotFoundBehavior notFoundBehavior = NotFoundBehavior.Throw) { IEntityHandleObject obj = _resolvedTokens.GetOrCreateValue(handle); if (obj is EcmaObjectLookupWrapper) @@ -394,7 +394,7 @@ public Object GetObject(EntityHandle handle, NotFoundBehavior notFoundBehavior = } } - private Object ResolveMethodSpecification(MethodSpecificationHandle handle) + private object ResolveMethodSpecification(MethodSpecificationHandle handle) { MethodSpecification methodSpecification = _metadataReader.GetMethodSpecification(handle); @@ -404,7 +404,7 @@ private Object ResolveMethodSpecification(MethodSpecificationHandle handle) MethodDesc methodDef = resolvedMethod as MethodDesc; if (methodDef == null) - ThrowHelper.ThrowBadImageFormatException($"method expected for handle {handle.ToString()}"); + ThrowHelper.ThrowBadImageFormatException($"method expected for handle {handle}"); BlobReader signatureReader = _metadataReader.GetBlobReader(methodSpecification.Signature); EcmaSignatureParser parser = new EcmaSignatureParser(this, signatureReader, NotFoundBehavior.ReturnResolutionFailure); @@ -417,7 +417,7 @@ private Object ResolveMethodSpecification(MethodSpecificationHandle handle) return Context.GetInstantiatedMethod(methodDef, new Instantiation(instantiation)); } - private Object ResolveStandaloneSignature(StandaloneSignatureHandle handle) + private object ResolveStandaloneSignature(StandaloneSignatureHandle handle) { StandaloneSignature signature = _metadataReader.GetStandaloneSignature(handle); BlobReader signatureReader = _metadataReader.GetBlobReader(signature.Signature); @@ -429,7 +429,7 @@ private Object ResolveStandaloneSignature(StandaloneSignatureHandle handle) return methodSig; } - private Object ResolveTypeSpecification(TypeSpecificationHandle handle) + private object ResolveTypeSpecification(TypeSpecificationHandle handle) { TypeSpecification typeSpecification = _metadataReader.GetTypeSpecification(handle); @@ -443,11 +443,11 @@ private Object ResolveTypeSpecification(TypeSpecificationHandle handle) return parsedType; } - private Object ResolveMemberReference(MemberReferenceHandle handle) + private object ResolveMemberReference(MemberReferenceHandle handle) { MemberReference memberReference = _metadataReader.GetMemberReference(handle); - Object parent = GetObject(memberReference.Parent, NotFoundBehavior.ReturnResolutionFailure); + object parent = GetObject(memberReference.Parent, NotFoundBehavior.ReturnResolutionFailure); if (parent is ResolutionFailure) return parent; @@ -533,11 +533,11 @@ private Object ResolveMemberReference(MemberReferenceHandle handle) return null; } - private Object ResolveTypeReference(TypeReferenceHandle handle) + private object ResolveTypeReference(TypeReferenceHandle handle) { TypeReference typeReference = _metadataReader.GetTypeReference(handle); - Object resolutionScope = GetObject(typeReference.ResolutionScope, NotFoundBehavior.ReturnResolutionFailure); + object resolutionScope = GetObject(typeReference.ResolutionScope, NotFoundBehavior.ReturnResolutionFailure); if (resolutionScope is ResolutionFailure) { return resolutionScope; @@ -564,7 +564,7 @@ private Object ResolveTypeReference(TypeReferenceHandle handle) throw new NotImplementedException(); } - private Object ResolveAssemblyReference(AssemblyReferenceHandle handle) + private object ResolveAssemblyReference(AssemblyReferenceHandle handle) { AssemblyReference assemblyReference = _metadataReader.GetAssemblyReference(handle); @@ -592,22 +592,20 @@ private Object ResolveAssemblyReference(AssemblyReferenceHandle handle) return assembly; } - private Object ResolveExportedType(ExportedTypeHandle handle) + private object ResolveExportedType(ExportedTypeHandle handle) { ExportedType exportedType = _metadataReader.GetExportedType(handle); var implementation = GetObject(exportedType.Implementation, NotFoundBehavior.ReturnResolutionFailure); - if (implementation is ModuleDesc) + if (implementation is ModuleDesc module) { - var module = (ModuleDesc)implementation; string nameSpace = _metadataReader.GetString(exportedType.Namespace); string name = _metadataReader.GetString(exportedType.Name); return module.GetType(nameSpace, name, NotFoundBehavior.ReturnResolutionFailure); } else - if (implementation is MetadataType) + if (implementation is MetadataType type) { - var type = (MetadataType)implementation; string name = _metadataReader.GetString(exportedType.Name); var nestedType = type.GetNestedType(name); if (nestedType == null) diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureEncoder.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureEncoder.cs index 68110e076d3ce..275cbcb6058d4 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureEncoder.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureEncoder.cs @@ -3,12 +3,9 @@ using System; using System.Collections.Immutable; -using System.Reflection; using System.Reflection.Metadata.Ecma335; using System.Reflection.Metadata; -using Internal.TypeSystem; - namespace Internal.TypeSystem.Ecma { public interface IEntityHandleProvider @@ -20,7 +17,7 @@ public interface IEntityHandleProvider public class EcmaSignatureEncoder where TEntityHandleProvider : IEntityHandleProvider { - TEntityHandleProvider _entityHandleProvider; + private TEntityHandleProvider _entityHandleProvider; public EcmaSignatureEncoder(TEntityHandleProvider entityHandleProvider) { diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs index f2530ec8b19d7..4df655766af0e 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs @@ -3,11 +3,8 @@ using System; using System.Reflection.Metadata; -using System.Runtime.InteropServices; using System.Diagnostics; using System.Text; - -using Internal.TypeSystem; using System.Collections.Generic; namespace Internal.TypeSystem.Ecma @@ -49,10 +46,9 @@ public EcmaSignatureParser(EcmaModule ecmaModule, BlobReader reader, NotFoundBeh _resolutionFailure = null; } - void SetResolutionFailure(ResolutionFailure failure) + private void SetResolutionFailure(ResolutionFailure failure) { - if (_resolutionFailure == null) - _resolutionFailure = failure; + _resolutionFailure ??= failure; } public ResolutionFailure ResolutionFailure => _resolutionFailure; @@ -100,10 +96,7 @@ private TypeDesc ParseType(SignatureTypeCode typeCode) _indexStack.Push(0); } TypeDesc result = ParseTypeImpl(typeCode); - if (_indexStack != null) - { - _indexStack.Pop(); - } + _indexStack?.Pop(); return result; } @@ -270,10 +263,7 @@ private SignatureTypeCode ParseTypeCode(bool skipPinned = true) _indexStack.Push(0); } SignatureTypeCode result = ParseTypeCodeImpl(skipPinned); - if (_indexStack != null) - { - _indexStack.Pop(); - } + _indexStack?.Pop(); return result; } @@ -286,20 +276,14 @@ private SignatureTypeCode ParseTypeCodeImpl(bool skipPinned = true) if (typeCode == SignatureTypeCode.RequiredModifier) { EntityHandle typeHandle = _reader.ReadTypeHandle(); - if (_embeddedSignatureDataList != null) - { - _embeddedSignatureDataList.Add(new EmbeddedSignatureData { index = string.Join(".", _indexStack), kind = EmbeddedSignatureDataKind.RequiredCustomModifier, type = ResolveHandle(typeHandle) }); - } + _embeddedSignatureDataList?.Add(new EmbeddedSignatureData { index = string.Join(".", _indexStack), kind = EmbeddedSignatureDataKind.RequiredCustomModifier, type = ResolveHandle(typeHandle) }); continue; } if (typeCode == SignatureTypeCode.OptionalModifier) { EntityHandle typeHandle = _reader.ReadTypeHandle(); - if (_embeddedSignatureDataList != null) - { - _embeddedSignatureDataList.Add(new EmbeddedSignatureData { index = string.Join(".", _indexStack), kind = EmbeddedSignatureDataKind.OptionalCustomModifier, type = ResolveHandle(typeHandle) }); - } + _embeddedSignatureDataList?.Add(new EmbeddedSignatureData { index = string.Join(".", _indexStack), kind = EmbeddedSignatureDataKind.OptionalCustomModifier, type = ResolveHandle(typeHandle) }); continue; } @@ -323,10 +307,7 @@ public TypeDesc ParseType() _indexStack.Push(0); } TypeDesc result = ParseTypeImpl(); - if (_indexStack != null) - { - _indexStack.Pop(); - } + _indexStack?.Pop(); return result; } @@ -370,10 +351,7 @@ private MethodSignature ParseMethodSignatureInternal(bool skipEmbeddedSignatureD _indexStack.Push(0); } MethodSignature result = ParseMethodSignatureImpl(skipEmbeddedSignatureData); - if (_indexStack != null) - { - _indexStack.Pop(); - } + _indexStack?.Pop(); return result; } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureTranslator.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureTranslator.cs index dd7e01fec9e4a..96045c035358a 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureTranslator.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureTranslator.cs @@ -9,10 +9,10 @@ namespace Internal.TypeSystem.Ecma { public struct EcmaSignatureTranslator { - BlobReader _input; - BlobBuilder _output; + private BlobReader _input; + private BlobBuilder _output; - Func _getAlternateStreamToken; + private Func _getAlternateStreamToken; public EcmaSignatureTranslator(BlobReader input, BlobBuilder output, Func getAlternateStreamToken) { @@ -23,31 +23,31 @@ public EcmaSignatureTranslator(BlobReader input, BlobBuilder output, Func foundRecords = new ArrayBuilder(); + ArrayBuilder foundRecords = default(ArrayBuilder); foreach (var methodImplHandle in _typeDefinition.GetMethodImplementations()) { @@ -79,7 +74,7 @@ public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string de protected override MethodImplRecord[] ComputeVirtualMethodImplsForType() { - ArrayBuilder records = new ArrayBuilder(); + ArrayBuilder records = default(ArrayBuilder); MetadataReader metadataReader = _module.MetadataReader; @@ -90,8 +85,8 @@ protected override MethodImplRecord[] ComputeVirtualMethodImplsForType() EntityHandle methodDeclCheckHandle = methodImpl.MethodDeclaration; HandleKind methodDeclHandleKind = methodDeclCheckHandle.Kind; - // We want to check that the type is not an interface matches before actually getting the MethodDesc. - // For MethodSpecifications we need to dereference that handle to the underlying member reference to + // We want to check that the type is not an interface matches before actually getting the MethodDesc. + // For MethodSpecifications we need to dereference that handle to the underlying member reference to // look at the owning type. if (methodDeclHandleKind == HandleKind.MethodSpecification) { diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.Serialization.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.Serialization.cs index 0f826f68936bc..9cfd879b023ac 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.Serialization.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.Serialization.cs @@ -5,7 +5,7 @@ namespace Internal.TypeSystem.Ecma { - partial class EcmaType + public partial class EcmaType { public override bool IsSerializable { diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.Sorting.cs index 2f0aefcab743b..f8443196adf2d 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.Sorting.cs @@ -6,7 +6,7 @@ namespace Internal.TypeSystem.Ecma { // Functionality related to deterministic ordering of types - partial class EcmaType + public partial class EcmaType { protected internal override int ClassCode => 1340416537; diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs index fe041b71b6ae2..245c51458a453 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs @@ -7,7 +7,6 @@ using System.Reflection.Metadata; using System.Reflection.Metadata.Ecma335; using System.Threading; -using Debug = System.Diagnostics.Debug; using Internal.NativeFormat; @@ -106,7 +105,7 @@ private void ComputeGenericParameters() } else { - _genericParameters = TypeDesc.EmptyTypes; + _genericParameters = EmptyTypes; } } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/IEcmaModule.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/IEcmaModule.cs index 816906f7cb9ad..4aee7b4ac009a 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/IEcmaModule.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/IEcmaModule.cs @@ -1,12 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; -using System.Reflection; using System.Reflection.Metadata; -using System.Reflection.Metadata.Ecma335; -using System.Reflection.PortableExecutable; using Internal.TypeSystem.Ecma; @@ -48,7 +43,7 @@ public interface IEcmaModule { MetadataReader MetadataReader { get; } TypeDesc GetType(EntityHandle handle); - Object GetObject(EntityHandle handle, NotFoundBehavior notFoundBehavior = NotFoundBehavior.Throw); + object GetObject(EntityHandle handle, NotFoundBehavior notFoundBehavior = NotFoundBehavior.Throw); int CompareTo(IEcmaModule other); int ModuleTypeSort { get; } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/IMetadataStringDecoderProvider.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/IMetadataStringDecoderProvider.cs index b37bec733a588..2dccf664c5f17 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/IMetadataStringDecoderProvider.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/IMetadataStringDecoderProvider.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Reflection.Metadata; namespace Internal.TypeSystem.Ecma diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/MetadataExtensions.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/MetadataExtensions.cs index d021fb01be2be..640a70efa7ce6 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/MetadataExtensions.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/MetadataExtensions.cs @@ -122,7 +122,7 @@ public static CustomAttributeHandle GetCustomAttributeHandle(this MetadataReader return default(CustomAttributeHandle); } - private static bool IsEqualCustomAttributeName(CustomAttributeHandle attributeHandle, MetadataReader metadataReader, + private static bool IsEqualCustomAttributeName(CustomAttributeHandle attributeHandle, MetadataReader metadataReader, string attributeNamespace, string attributeName) { StringHandle namespaceHandle, nameHandle; @@ -136,8 +136,8 @@ private static bool IsEqualCustomAttributeName(CustomAttributeHandle attributeHa public static bool GetAttributeNamespaceAndName(this MetadataReader metadataReader, CustomAttributeHandle attributeHandle, out StringHandle namespaceHandle, out StringHandle nameHandle) { - EntityHandle attributeType, attributeCtor; - if (!GetAttributeTypeAndConstructor(metadataReader, attributeHandle, out attributeType, out attributeCtor)) + EntityHandle attributeType; + if (!GetAttributeTypeAndConstructor(metadataReader, attributeHandle, out attributeType, out _)) { namespaceHandle = default(StringHandle); nameHandle = default(StringHandle); @@ -211,7 +211,7 @@ public static bool GetAttributeTypeNamespaceAndName(this MetadataReader metadata public static PInvokeFlags GetDelegatePInvokeFlags(this EcmaType type) { PInvokeFlags flags = new PInvokeFlags(PInvokeAttributes.PreserveSig); - + if (!type.IsDelegate) { return flags; diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/SymbolReader/PortablePdbSymbolReader.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/SymbolReader/PortablePdbSymbolReader.cs index 4baae1590cff7..17cee6d38cc8c 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/SymbolReader/PortablePdbSymbolReader.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/SymbolReader/PortablePdbSymbolReader.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using System.IO; using System.IO.MemoryMappedFiles; @@ -105,8 +104,7 @@ private PortablePdbSymbolReader(MetadataReader reader, MemoryMappedViewAccessor public override void Dispose() { - if (_mappedViewAccessor != null) - _mappedViewAccessor.Dispose(); + _mappedViewAccessor?.Dispose(); } public override int GetStateMachineKickoffMethod(int methodToken) diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/SymbolReader/UnmanagedPdbSymbolReader.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/SymbolReader/UnmanagedPdbSymbolReader.cs index d4b6f3686be99..40979241487ab 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/SymbolReader/UnmanagedPdbSymbolReader.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/SymbolReader/UnmanagedPdbSymbolReader.cs @@ -8,7 +8,6 @@ using System.Runtime.InteropServices; using System.Collections; using System.Diagnostics; -using System.Runtime.InteropServices.ComTypes; using System.Runtime.CompilerServices; #if !DISABLE_UNMANAGED_PDB_SYMBOLS @@ -48,7 +47,7 @@ private static int CLRCreateInstance(ref Guid clsid, ref Guid riid, out ClrMetaH static extern int CLRCreateInstance(ref Guid clsid, ref Guid riid, out IntPtr ptr); } - interface ICLRMetaHost + private interface ICLRMetaHost { public static readonly Guid IID = new Guid("d332db9e-b9b3-4125-8207-a14884f53216"); @@ -78,7 +77,7 @@ protected override object CreateObject(IntPtr externalComObject, CreateObjectFla protected override void ReleaseObjects(IEnumerable objects) => throw new NotImplementedException(); - public unsafe class ClrMetaHostRcw : ICLRMetaHost, IDisposable + public sealed unsafe class ClrMetaHostRcw : ICLRMetaHost, IDisposable { private bool _disposed; private readonly IntPtr _inst; @@ -125,7 +124,7 @@ private void DisposeInternal() } } - interface ICLRRuntimeInfo + private interface ICLRRuntimeInfo { int GetInterface(ref Guid rclsid, ref Guid riid, out MetaDataDispenserWrapperCache.MetaDataDispenserRcw? ppUnk); @@ -134,7 +133,7 @@ interface ICLRRuntimeInfo // Don't need any other methods. } - private class CLRRuntimeInfoWrapperCache : ComWrappers + private sealed class CLRRuntimeInfoWrapperCache : ComWrappers { public static readonly CLRRuntimeInfoWrapperCache Instance = new CLRRuntimeInfoWrapperCache(); private CLRRuntimeInfoWrapperCache() { } @@ -159,7 +158,7 @@ private enum VtableOffset BindAsLegacyV2Runtime = 13 } - private bool _disposed = false; + private bool _disposed; public int GetInterface(ref Guid rclsid, ref Guid riid, out MetaDataDispenserWrapperCache.MetaDataDispenserRcw? ppUnk) { @@ -230,7 +229,7 @@ protected override object CreateObject(IntPtr externalComObject, CreateObjectFla public sealed unsafe record MetaDataDispenserRcw(IntPtr Inst) : IMetaDataDispenser, IDisposable { - private bool _disposed = false; + private bool _disposed; /// /// is simply a boxed IntPtr, because we don't need an RCW. @@ -293,9 +292,9 @@ private CoCreateWrapperCache() { } } protected override void ReleaseObjects(IEnumerable objects) => throw new NotImplementedException(); - public unsafe record SymUnmanagedBinderRcw(IntPtr Inst) : ISymUnmanagedBinder + public sealed unsafe record SymUnmanagedBinderRcw(IntPtr Inst) : ISymUnmanagedBinder { - private bool _disposed = false; + private bool _disposed; public int GetReaderForFile(MetadataImportRcw metadataImporter, string fileName, string searchPath, out SymUnmanagedReaderWrapperCache.SymUnmanagedReaderRcw? reader) { @@ -343,7 +342,7 @@ private void DisposeInternal() /// private sealed record MetadataImportRcw(IntPtr Ptr) : IDisposable { - private bool _disposed = false; + private bool _disposed; public void Dispose() { @@ -363,7 +362,7 @@ private void DisposeInternal() } } - interface ISymUnmanagedReader + private interface ISymUnmanagedReader { int GetMethod(int methodToken, out ISymUnmanagedMethod? method); // No more members are used @@ -383,7 +382,7 @@ private sealed class SymUnmanagedNamespaceWrapperCache : ComWrappers public sealed unsafe record SymUnmanagedNamespaceRcw(IntPtr Inst) : ISymUnmanagedNamespace { - private bool _disposed = false; + private bool _disposed; public int GetName(int bufferLength, out int count, char[] name) { @@ -418,7 +417,7 @@ public int GetNamespaces(int bufferLength, out int count, ISymUnmanagedNamespace { for (int i = 0; i < count; i++) { - namespaces[i] = (SymUnmanagedNamespaceWrapperCache.SymUnmanagedNamespaceRcw)SymUnmanagedNamespaceWrapperCache.Instance.GetOrCreateObjectForComInstance(intermediate[i], CreateObjectFlags.UniqueInstance); + namespaces[i] = (SymUnmanagedNamespaceWrapperCache.SymUnmanagedNamespaceRcw)Instance.GetOrCreateObjectForComInstance(intermediate[i], CreateObjectFlags.UniqueInstance); } } } @@ -496,7 +495,7 @@ private sealed class SymUnmanagedVariableWrapperCache : ComWrappers public sealed unsafe record SymUnmanagedVariableRcw(IntPtr Inst) : ISymUnmanagedVariable { - private bool _disposed = false; + private bool _disposed; public int GetName(int bufferLength, out int count, char[] name) { @@ -580,7 +579,7 @@ private sealed class SymUnmanagedScopeWrapperCache : ComWrappers public sealed unsafe record SymUnmanagedScopeRcw(IntPtr Inst) : ISymUnmanagedScope { - private bool _disposed = false; + private bool _disposed; public int GetMethod(out ISymUnmanagedMethod? method) { @@ -599,7 +598,7 @@ public int GetParent(out ISymUnmanagedScope? scope) IntPtr scopePtr; int hr = func(Inst, &scopePtr); scope = hr == 0 - ? (SymUnmanagedScopeWrapperCache.SymUnmanagedScopeRcw)SymUnmanagedScopeWrapperCache.Instance.GetOrCreateObjectForComInstance(scopePtr, CreateObjectFlags.UniqueInstance) + ? (SymUnmanagedScopeWrapperCache.SymUnmanagedScopeRcw)Instance.GetOrCreateObjectForComInstance(scopePtr, CreateObjectFlags.UniqueInstance) : null; return hr; } @@ -627,7 +626,7 @@ public int GetChildren(int bufferLength, out int count, ISymUnmanagedScope[] chi { for (int i = 0; i < count; i++) { - children[i] = (SymUnmanagedScopeWrapperCache.SymUnmanagedScopeRcw)SymUnmanagedScopeWrapperCache.Instance.GetOrCreateObjectForComInstance(intermediate[i], CreateObjectFlags.UniqueInstance); + children[i] = (SymUnmanagedScopeWrapperCache.SymUnmanagedScopeRcw)Instance.GetOrCreateObjectForComInstance(intermediate[i], CreateObjectFlags.UniqueInstance); } } } @@ -751,9 +750,9 @@ private sealed class SymUnmanagedDocumentWrapperCache : ComWrappers } protected override void ReleaseObjects(IEnumerable objects) => throw new NotImplementedException(); - public unsafe record SymUnmanagedDocumentRcw(IntPtr Inst) : ISymUnmanagedDocument + public sealed unsafe record SymUnmanagedDocumentRcw(IntPtr Inst) : ISymUnmanagedDocument { - private bool _disposed = false; + private bool _disposed; public int GetUrl(int bufferLength, out int count, char[] url) { @@ -864,7 +863,7 @@ private sealed class SymUnmanagedMethodWrapperCache : ComWrappers public sealed unsafe record SymUnmanagedMethodRcw(IntPtr Inst) : ISymUnmanagedMethod { - private bool _disposed = false; + private bool _disposed; public int GetToken(out int methodToken) { @@ -1080,7 +1079,7 @@ protected override object CreateObject(IntPtr externalComObject, CreateObjectFla /// public sealed record SymUnmanagedReaderRcw(IntPtr Inst) : ISymUnmanagedReader { - private bool _disposed = false; + private bool _disposed; public unsafe int GetMethod(int methodToken, out ISymUnmanagedMethod? method) { @@ -1127,7 +1126,7 @@ int GetReaderForFile( } private static int CoCreateInstance(ref Guid rclsid, IntPtr pUnkOuter, - Int32 dwClsContext, + int dwClsContext, ref Guid riid, out CoCreateWrapperCache.SymUnmanagedBinderRcw? ppv) { @@ -1140,19 +1139,21 @@ private static int CoCreateInstance(ref Guid rclsid, IntPtr pUnkOuter, [DllImport("ole32.dll")] static extern int CoCreateInstance(ref Guid rclsid, IntPtr pUnkOuter, - Int32 dwClsContext, + int dwClsContext, ref Guid riid, out IntPtr ppv); } - private void ThrowExceptionForHR(int hr) + private static void ThrowExceptionForHR(int hr) { Marshal.ThrowExceptionForHR(hr, new IntPtr(-1)); } private static readonly Guid SymBinderIID = new Guid(0x0a29ff9e, 0x7f9c, 0x4437, 0x8b, 0x11, 0xf4, 0x24, 0x49, 0x1e, 0x39, 0x31); +#pragma warning disable CA1810 // Initialize reference type static fields inline static UnmanagedPdbSymbolReader() +#pragma warning restore CA1810 // Initialize reference type static fields inline { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { @@ -1202,8 +1203,8 @@ static UnmanagedPdbSymbolReader() } } - private readonly static MetaDataDispenserWrapperCache.MetaDataDispenserRcw? s_metadataDispenser; - private readonly static CoCreateWrapperCache.SymUnmanagedBinderRcw? s_symBinder; + private static readonly MetaDataDispenserWrapperCache.MetaDataDispenserRcw? s_metadataDispenser; + private static readonly CoCreateWrapperCache.SymUnmanagedBinderRcw? s_symBinder; public static PdbSymbolReader? TryOpenSymbolReaderForMetadataFile(string metadataFileName, string searchPath) { @@ -1252,8 +1253,7 @@ private string GetUrl(ISymUnmanagedDocument doc) { lock (this) { - if (_urlCache == null) - _urlCache = new Dictionary(); + _urlCache ??= new Dictionary(); if (_urlCache.TryGetValue(doc, out var url)) return url; @@ -1323,7 +1323,7 @@ private void ProbeScopeForLocals(List variables, ISymUnmanagedS int attributes; ThrowExceptionForHR(local.GetAttributes(out attributes)); - variables.Add(new ILLocalVariable(slot, new String(nameBuffer, 0, nameLength - 1), (attributes & 0x1) != 0)); + variables.Add(new ILLocalVariable(slot, new string(nameBuffer, 0, nameLength - 1), (attributes & 0x1) != 0)); } int childrenCount; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/DelegateInfo.cs b/src/coreclr/tools/Common/TypeSystem/IL/DelegateInfo.cs index 1edcea5516975..11c803cf7617d 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/DelegateInfo.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/DelegateInfo.cs @@ -71,10 +71,7 @@ public MethodSignature Signature { get { - if (_signature == null) - { - _signature = _delegateType.GetKnownMethod("Invoke", null).Signature; - } + _signature ??= _delegateType.GetKnownMethod("Invoke", null).Signature; return _signature; } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/EcmaMethodIL.Symbols.cs b/src/coreclr/tools/Common/TypeSystem/IL/EcmaMethodIL.Symbols.cs index ade8a64726cee..46c30699408ab 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/EcmaMethodIL.Symbols.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/EcmaMethodIL.Symbols.cs @@ -12,7 +12,7 @@ namespace Internal.IL { // Pluggable file that adds PDB handling functionality to EcmaMethodIL - partial class EcmaMethodIL + public partial class EcmaMethodIL { public override MethodDebugInformation GetDebugInfo() { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/HelperExtensions.cs b/src/coreclr/tools/Common/TypeSystem/IL/HelperExtensions.cs index 66344ff698d16..4ccaff2d6dd9f 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/HelperExtensions.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/HelperExtensions.cs @@ -69,7 +69,7 @@ public static MethodDesc GetKnownMethod(this TypeDesc type, string name, MethodS MethodDesc method = type.GetMethod(name, signature); if (method == null) { - throw new InvalidOperationException(String.Format("Expected method '{0}' not found on type '{1}'", name, type)); + throw new InvalidOperationException(string.Format("Expected method '{0}' not found on type '{1}'", name, type)); } return method; @@ -84,7 +84,7 @@ public static FieldDesc GetKnownField(this TypeDesc type, string name) FieldDesc field = type.GetField(name); if (field == null) { - throw new InvalidOperationException(String.Format("Expected field '{0}' not found on type '{1}'", name, type)); + throw new InvalidOperationException(string.Format("Expected field '{0}' not found on type '{1}'", name, type)); } return field; @@ -99,7 +99,7 @@ public static MetadataType GetKnownNestedType(this MetadataType type, string nam MetadataType nestedType = type.GetNestedType(name); if (nestedType == null) { - throw new InvalidOperationException(String.Format("Expected type '{0}' not found on type '{1}'", name, type)); + throw new InvalidOperationException(string.Format("Expected type '{0}' not found on type '{1}'", name, type)); } return nestedType; @@ -115,8 +115,8 @@ public static MetadataType GetKnownType(this ModuleDesc module, string @namespac if (type == null) { throw new InvalidOperationException( - String.Format("Expected type '{0}' not found in module '{1}'", - @namespace.Length > 0 ? String.Concat(@namespace, ".", name) : name, + string.Format("Expected type '{0}' not found in module '{1}'", + @namespace.Length > 0 ? string.Concat(@namespace, ".", name) : name, module)); } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/ILDisassembler.cs b/src/coreclr/tools/Common/TypeSystem/IL/ILDisassembler.cs index f11ed8cf5db8e..864850ecc9cc2 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/ILDisassembler.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/ILDisassembler.cs @@ -143,7 +143,7 @@ private void AppendFieldSignature(StringBuilder sb, FieldDesc field) sb.Append(field.Name); } - private void AppendStringLiteral(StringBuilder sb, string s) + private static void AppendStringLiteral(StringBuilder sb, string s) { sb.Append('"'); for (int i = 0; i < s.Length; i++) @@ -187,20 +187,21 @@ private byte ReadILByte() return _ilBytes[_currentOffset++]; } - private UInt16 ReadILUInt16() + private ushort ReadILUInt16() { - UInt16 val = (UInt16)(_ilBytes[_currentOffset] + (_ilBytes[_currentOffset + 1] << 8)); + ushort val = (ushort)(_ilBytes[_currentOffset] + (_ilBytes[_currentOffset + 1] << 8)); _currentOffset += 2; return val; } - private UInt32 ReadILUInt32() + private uint ReadILUInt32() { - UInt32 val = (UInt32)(_ilBytes[_currentOffset] + (_ilBytes[_currentOffset + 1] << 8) + (_ilBytes[_currentOffset + 2] << 16) + (_ilBytes[_currentOffset + 3] << 24)); + uint val = (uint)(_ilBytes[_currentOffset] + (_ilBytes[_currentOffset + 1] << 8) + (_ilBytes[_currentOffset + 2] << 16) + (_ilBytes[_currentOffset + 3] << 24)); _currentOffset += 4; return val; } + private int ReadILToken() { return (int)ReadILUInt32(); @@ -418,7 +419,7 @@ public string GetNextInstruction() int delta = (int)ReadILUInt32(); AppendOffset(decodedInstruction, jmpBase + delta); } - decodedInstruction.Append(")"); + decodedInstruction.Append(')'); return decodedInstruction.ToString(); } @@ -493,7 +494,7 @@ public override void AppendName(StringBuilder sb, SignatureMethodVariable type) public override void AppendName(StringBuilder sb, SignatureTypeVariable type) { - sb.Append("!"); + sb.Append('!'); sb.Append(type.Index.ToStringInvariant()); } @@ -514,7 +515,7 @@ protected override void AppendNameForInstantiatedType(StringBuilder sb, DefType if (i > 0) sb.Append(", "); AppendNameWithValueClassPrefix(sb, type.Instantiation[i]); - } + } sb.Append('>'); } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/ILImporter.cs b/src/coreclr/tools/Common/TypeSystem/IL/ILImporter.cs index 8f4cb7440c71a..1ac634591cd12 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/ILImporter.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/ILImporter.cs @@ -1,14 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.TypeSystem; -using Internal.IL; namespace Internal.IL { - internal partial class ILImporter + internal sealed partial class ILImporter { private BasicBlock[] _basicBlocks; // Maps IL offset to basic block @@ -29,22 +26,22 @@ private byte ReadILByte() return _ilBytes[_currentOffset++]; } - private UInt16 ReadILUInt16() + private ushort ReadILUInt16() { if (_currentOffset + 1 >= _ilBytes.Length) ReportMethodEndInsideInstruction(); - UInt16 val = (UInt16)(_ilBytes[_currentOffset] + (_ilBytes[_currentOffset + 1] << 8)); + ushort val = (ushort)(_ilBytes[_currentOffset] + (_ilBytes[_currentOffset + 1] << 8)); _currentOffset += 2; return val; } - private UInt32 ReadILUInt32() + private uint ReadILUInt32() { if (_currentOffset + 3 >= _ilBytes.Length) ReportMethodEndInsideInstruction(); - UInt32 val = (UInt32)(_ilBytes[_currentOffset] + (_ilBytes[_currentOffset + 1] << 8) + (_ilBytes[_currentOffset + 2] << 16) + (_ilBytes[_currentOffset + 3] << 24)); + uint val = (uint)(_ilBytes[_currentOffset] + (_ilBytes[_currentOffset + 1] << 8) + (_ilBytes[_currentOffset + 2] << 16) + (_ilBytes[_currentOffset + 3] << 24)); _currentOffset += 4; return val; } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/ILOpcode.cs b/src/coreclr/tools/Common/TypeSystem/IL/ILOpcode.cs index f3a11e0074dc8..3a332e2346398 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/ILOpcode.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/ILOpcode.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace Internal.IL { /// diff --git a/src/coreclr/tools/Common/TypeSystem/IL/ILReader.cs b/src/coreclr/tools/Common/TypeSystem/IL/ILReader.cs index d722b2e171289..d0022a5bad78b 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/ILReader.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/ILReader.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; @@ -55,22 +54,22 @@ public byte ReadILByte() return _ilBytes[_currentOffset++]; } - public UInt16 ReadILUInt16() + public ushort ReadILUInt16() { if (_currentOffset + 2 > _ilBytes.Length) ThrowHelper.ThrowInvalidProgramException(); - UInt16 val = (UInt16)(_ilBytes[_currentOffset] + (_ilBytes[_currentOffset + 1] << 8)); + ushort val = (ushort)(_ilBytes[_currentOffset] + (_ilBytes[_currentOffset + 1] << 8)); _currentOffset += 2; return val; } - public UInt32 ReadILUInt32() + public uint ReadILUInt32() { if (_currentOffset + 4 > _ilBytes.Length) ThrowHelper.ThrowInvalidProgramException(); - UInt32 val = (UInt32)(_ilBytes[_currentOffset] + (_ilBytes[_currentOffset + 1] << 8) + (_ilBytes[_currentOffset + 2] << 16) + (_ilBytes[_currentOffset + 3] << 24)); + uint val = (uint)(_ilBytes[_currentOffset] + (_ilBytes[_currentOffset + 1] << 8) + (_ilBytes[_currentOffset + 2] << 16) + (_ilBytes[_currentOffset + 3] << 24)); _currentOffset += 4; return val; } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/ILStackHelper.cs b/src/coreclr/tools/Common/TypeSystem/IL/ILStackHelper.cs index 19c643256b4b0..1204f1b6655f3 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/ILStackHelper.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/ILStackHelper.cs @@ -24,7 +24,7 @@ public static void CheckStackBalance(this MethodIL methodIL) /// public static int ComputeMaxStack(this MethodIL methodIL) { - const int StackHeightNotSet = Int32.MinValue; + const int StackHeightNotSet = int.MinValue; byte[] ilbytes = methodIL.GetILBytes(); int currentOffset = 0; @@ -278,7 +278,7 @@ public static int ComputeMaxStack(this MethodIL methodIL) stackHeight = StackHeightNotSet; } break; - + case ILOpcode.call: case ILOpcode.calli: case ILOpcode.callvirt: diff --git a/src/coreclr/tools/Common/TypeSystem/IL/ILTokenReplacer.cs b/src/coreclr/tools/Common/TypeSystem/IL/ILTokenReplacer.cs index cc6dca8ef20d7..63c2a7fe4cbab 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/ILTokenReplacer.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/ILTokenReplacer.cs @@ -29,7 +29,7 @@ public static void Replace(byte[] ilStream, Func tokenReplaceFunc) // Replace token in IL stream with a new token provided by the tokenReplaceFunc // // This is used by the StandaloneMethodMetadata logic to create method local tokens - // and by the IL provider used for cross module inlining to create tokens which are + // and by the IL provider used for cross module inlining to create tokens which are // stable and contained within the R2R module instead of being in a module separated // by a version boundary. int token = BinaryPrimitives.ReadInt32LittleEndian(tokenSpan); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/InstantiatedMethodIL.cs b/src/coreclr/tools/Common/TypeSystem/IL/InstantiatedMethodIL.cs index 9def3ed499b8b..5d4fb39c953a1 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/InstantiatedMethodIL.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/InstantiatedMethodIL.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; @@ -21,7 +19,7 @@ public InstantiatedMethodIL(MethodDesc owningMethod, MethodIL methodIL) Debug.Assert(methodIL.GetMethodILDefinition() == methodIL); Debug.Assert(owningMethod.HasInstantiation || owningMethod.OwningType.HasInstantiation); Debug.Assert(owningMethod.GetTypicalMethodDefinition() == methodIL.OwningMethod); - + _methodIL = methodIL; _method = owningMethod; @@ -86,12 +84,12 @@ public override LocalVariableDefinition[] GetLocals() } } - return (clone == null) ? locals : clone; + return clone ?? locals; } - public override Object GetObject(int token, NotFoundBehavior notFoundBehavior) + public override object GetObject(int token, NotFoundBehavior notFoundBehavior) { - Object o = _methodIL.GetObject(token, notFoundBehavior); + object o = _methodIL.GetObject(token, notFoundBehavior); if (o is MethodDesc) { @@ -105,9 +103,8 @@ public override Object GetObject(int token, NotFoundBehavior notFoundBehavior) { o = ((FieldDesc)o).InstantiateSignature(_typeInstantiation, _methodInstantiation); } - else if (o is MethodSignature) + else if (o is MethodSignature template) { - MethodSignature template = (MethodSignature)o; MethodSignatureBuilder builder = new MethodSignatureBuilder(template); builder.ReturnType = template.ReturnType.InstantiateSignature(_typeInstantiation, _methodInstantiation); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/MethodIL.Symbols.cs b/src/coreclr/tools/Common/TypeSystem/IL/MethodIL.Symbols.cs index 849db1a5df10a..58990200f3775 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/MethodIL.Symbols.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/MethodIL.Symbols.cs @@ -4,11 +4,9 @@ using System; using System.Collections.Generic; -using Internal.TypeSystem; - namespace Internal.IL { - partial class MethodIL + public partial class MethodIL { public virtual MethodDebugInformation GetDebugInfo() { @@ -16,7 +14,7 @@ public virtual MethodDebugInformation GetDebugInfo() } } - partial class InstantiatedMethodIL + public partial class InstantiatedMethodIL { public override MethodDebugInformation GetDebugInfo() { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/MethodIL.cs b/src/coreclr/tools/Common/TypeSystem/IL/MethodIL.cs index 2f8b54249197e..13aee813f36af 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/MethodIL.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/MethodIL.cs @@ -1,14 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.TypeSystem; namespace Internal.IL { // - // This duplicates types from System.Reflection.Metadata to avoid layering issues, and + // This duplicates types from System.Reflection.Metadata to avoid layering issues, and // because of the System.Reflection.Metadata constructors are not public anyway. // @@ -73,7 +71,7 @@ public virtual MethodILScope GetMethodILScopeDefinition() /// (typically a , , , /// or ). /// - public abstract Object GetObject(int token, NotFoundBehavior notFoundBehavior = NotFoundBehavior.Throw); + public abstract object GetObject(int token, NotFoundBehavior notFoundBehavior = NotFoundBehavior.Throw); public override string ToString() { @@ -113,7 +111,7 @@ public abstract partial class MethodIL : MethodILScope /// public abstract ILExceptionRegion[] GetExceptionRegions(); - public override sealed MethodILScope GetMethodILScopeDefinition() + public sealed override MethodILScope GetMethodILScopeDefinition() { return GetMethodILDefinition(); } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/MethodILDebugView.cs b/src/coreclr/tools/Common/TypeSystem/IL/MethodILDebugView.cs index 03fc460d2582c..28b9818c3af1e 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/MethodILDebugView.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/MethodILDebugView.cs @@ -33,20 +33,20 @@ public string Disassembly if (!owningMethod.Signature.IsStatic) sb.Append("instance "); disasm.AppendType(sb, owningMethod.Signature.ReturnType); - sb.Append(" "); + sb.Append(' '); sb.Append(owningMethod.Name); if (owningMethod.HasInstantiation) { - sb.Append("<"); + sb.Append('<'); for (int i = 0; i < owningMethod.Instantiation.Length; i++) { if (i != 0) sb.Append(", "); disasm.AppendType(sb, owningMethod.Instantiation[i]); } - sb.Append(">"); + sb.Append('>'); } - sb.Append("("); + sb.Append('('); for (int i = 0; i < owningMethod.Signature.Length; i++) { if (i != 0) @@ -71,7 +71,7 @@ public string Disassembly if (_methodIL.IsInitLocals) sb.Append("init "); - sb.Append("("); + sb.Append('('); for (int i = 0; i < locals.Length; i++) { @@ -81,7 +81,7 @@ public string Disassembly sb.Append(' ', 6); } disasm.AppendType(sb, locals[i].Type); - sb.Append(" "); + sb.Append(' '); if (locals[i].IsPinned) sb.Append("pinned "); sb.Append("V_"); @@ -101,7 +101,7 @@ public string Disassembly ILDisassembler.AppendOffset(sb, region.TryOffset); sb.Append(" to "); ILDisassembler.AppendOffset(sb, region.TryOffset + region.TryLength); - + switch (region.Kind) { case ILExceptionRegionKind.Catch: diff --git a/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs b/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs index 5e3f6e62ec84f..2de9aa4f8c0fb 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs @@ -14,7 +14,7 @@ namespace Internal.IL { public sealed class NativeAotILProvider : ILProvider { - private MethodIL TryGetRuntimeImplementedMethodIL(MethodDesc method) + private static MethodIL TryGetRuntimeImplementedMethodIL(MethodDesc method) { // Provides method bodies for runtime implemented methods. It can return null for // methods that are treated specially by the codegen. @@ -36,7 +36,7 @@ private MethodIL TryGetRuntimeImplementedMethodIL(MethodDesc method) /// It can return null if it's not an intrinsic recognized by the compiler, /// but an intrinsic e.g. recognized by codegen. /// - private MethodIL TryGetIntrinsicMethodIL(MethodDesc method) + private static MethodIL TryGetIntrinsicMethodIL(MethodDesc method) { Debug.Assert(method.IsIntrinsic); @@ -108,7 +108,7 @@ private MethodIL TryGetIntrinsicMethodIL(MethodDesc method) /// are specialized per instantiation. It can return null if the intrinsic /// is not recognized. /// - private MethodIL TryGetPerInstantiationIntrinsicMethodIL(MethodDesc method) + private static MethodIL TryGetPerInstantiationIntrinsicMethodIL(MethodDesc method) { Debug.Assert(method.IsIntrinsic); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ArrayMethodILEmitter.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ArrayMethodILEmitter.cs index 6a57b848dfdb6..0c81ec3286200 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ArrayMethodILEmitter.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ArrayMethodILEmitter.cs @@ -30,7 +30,7 @@ private ArrayMethodILEmitter(ArrayMethod method) _emitter = new ILEmitter(); // This helper field is needed to generate proper GC tracking. There is no direct way - // to create interior pointer. + // to create interior pointer. _helperFieldToken = _emitter.NewToken(_method.Context.GetWellKnownType(WellKnownType.Object).GetKnownField("m_pEEType")); } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.Sorting.cs index 004388db62c15..fb12ea795a79d 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.Sorting.cs @@ -7,7 +7,7 @@ namespace Internal.IL.Stubs { // Functionality related to deterministic ordering of types - partial class AssemblyGetExecutingAssemblyMethodThunk + internal partial class AssemblyGetExecutingAssemblyMethodThunk { protected override int ClassCode => 1459986716; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs index ce1d69716a7b9..78386fbe55cb4 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs @@ -10,7 +10,7 @@ namespace Internal.IL.Stubs /// is to load something that will let us identify the current assembly and call a class library /// helper that will let us get the Assembly. /// - internal partial class AssemblyGetExecutingAssemblyMethodThunk : ILStubMethod + internal sealed partial class AssemblyGetExecutingAssemblyMethodThunk : ILStubMethod { public AssemblyGetExecutingAssemblyMethodThunk(TypeDesc owningType, IAssemblyDesc executingAssembly) { @@ -81,7 +81,7 @@ public override MethodIL EmitIL() } } - internal class AssemblyGetExecutingAssemblyMethodThunkCache + internal sealed class AssemblyGetExecutingAssemblyMethodThunkCache { private TypeDesc _owningTypeForThunks; private Unifier _cache; @@ -97,7 +97,7 @@ public MethodDesc GetHelper(IAssemblyDesc executingAssembly) return _cache.GetOrCreateValue(executingAssembly); } - private class Unifier : LockFreeReaderHashtable + private sealed class Unifier : LockFreeReaderHashtable { private AssemblyGetExecutingAssemblyMethodThunkCache _parent; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.Mangling.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.Mangling.cs index 95beb89a11add..fa3f8608f5032 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.Mangling.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.Mangling.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Diagnostics; using Internal.TypeSystem; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.Sorting.cs index cd6e620aa8607..86bd6fce3f81e 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.Sorting.cs @@ -6,7 +6,7 @@ namespace Internal.IL.Stubs { // Functionality related to deterministic ordering of methods - partial class CalliMarshallingMethodThunk + public partial class CalliMarshallingMethodThunk { protected override int ClassCode => 1594107963; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.cs index d0d397bafdf38..23721ea8e1c4c 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.cs @@ -1,11 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using Internal.TypeSystem; -using Internal.TypeSystem.Interop; -using Debug = System.Diagnostics.Debug; -using Internal.TypeSystem.Ecma; namespace Internal.IL.Stubs { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ComparerIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ComparerIntrinsics.cs index 91856de2d880d..db0dfa2cfe2c6 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ComparerIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ComparerIntrinsics.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using Internal.TypeSystem; @@ -165,7 +164,7 @@ private static TypeDesc[] GetPotentialComparersForTypeCommon(TypeDesc type, stri { // This can be any of the comparers we have. - ArrayBuilder universalComparers = new ArrayBuilder(); + ArrayBuilder universalComparers = default(ArrayBuilder); universalComparers.Add(context.SystemModule.GetKnownType("System.Collections.Generic", $"Nullable{flavor}`1") .MakeInstantiatedType(type)); @@ -182,7 +181,7 @@ private static TypeDesc[] GetPotentialComparersForTypeCommon(TypeDesc type, stri return universalComparers.ToArray(); } - + // This mirrors exactly what GetUnknownEquatableComparer and GetUnknownComparer (in the class library) // will need at runtime. This is the general purpose code path that can be used to compare // anything. @@ -203,7 +202,7 @@ private static TypeDesc[] GetPotentialComparersForTypeCommon(TypeDesc type, stri .MakeInstantiatedType(type), }; } - + return new TypeDesc[] { context.SystemModule.GetKnownType("System.Collections.Generic", $"Generic{flavor}`1") diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.Mangling.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.Mangling.cs index 0f8d28eb9e8f2..27dbb90c06c85 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.Mangling.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.Mangling.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using Internal.TypeSystem; namespace Internal.IL.Stubs diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.Sorting.cs index b38cd1fda8e54..43d1c94a72109 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.Sorting.cs @@ -6,7 +6,7 @@ namespace Internal.IL.Stubs { // Functionality related to deterministic ordering of methods - partial class DelegateMarshallingMethodThunk + public partial class DelegateMarshallingMethodThunk { protected override int ClassCode => 1018037605; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs index 5b09863069020..368f19a79a74c 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs @@ -101,7 +101,7 @@ public MetadataType DelegateType } } - private TypeDesc GetNativeMethodParameterType(TypeDesc managedType, MarshalAsDescriptor marshalAs, InteropStateManager interopStateManager, bool isReturn, bool isAnsi) + private static TypeDesc GetNativeMethodParameterType(TypeDesc managedType, MarshalAsDescriptor marshalAs, InteropStateManager interopStateManager, bool isReturn, bool isAnsi) { TypeDesc nativeType; try @@ -156,7 +156,7 @@ public override MethodSignature Signature marshalAs = parameterMetadataArray[parameterIndex++].MarshalAsDescriptor; } - TypeDesc nativeReturnType = GetNativeMethodParameterType(delegateSignature.ReturnType, + TypeDesc nativeReturnType = GetNativeMethodParameterType(delegateSignature.ReturnType, marshalAs, _interopStateManager, isReturn:true, @@ -180,7 +180,7 @@ public override MethodSignature Signature var managedType = isByRefType ? delegateSignature[i].GetParameterType() : delegateSignature[i]; - var nativeType = GetNativeMethodParameterType(managedType, + var nativeType = GetNativeMethodParameterType(managedType, marshalAs, _interopStateManager, isReturn:false, @@ -231,8 +231,8 @@ private string NamePrefix case DelegateMarshallingMethodThunkKind.ForwardNativeFunctionWrapper: return "ForwardNativeFunctionWrapper"; default: - System.Diagnostics.Debug.Fail("Unexpected DelegateMarshallingMethodThunkKind."); - return String.Empty; + Debug.Fail("Unexpected DelegateMarshallingMethodThunkKind."); + return string.Empty; } } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.Sorting.cs index 1126e01d4020b..fabf0153399ec 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.Sorting.cs @@ -6,7 +6,7 @@ namespace Internal.IL.Stubs { // Functionality related to deterministic ordering of types - partial class DelegateThunk + public partial class DelegateThunk { protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) { @@ -15,7 +15,7 @@ protected override int CompareToImpl(MethodDesc other, TypeSystemComparer compar } } - partial class DelegateInvokeOpenStaticThunk + public partial class DelegateInvokeOpenStaticThunk { protected override int ClassCode => 386356101; } @@ -25,27 +25,27 @@ public sealed partial class DelegateInvokeOpenInstanceThunk protected override int ClassCode => -1787190244; } - partial class DelegateInvokeClosedStaticThunk + public partial class DelegateInvokeClosedStaticThunk { protected override int ClassCode => 28195375; } - partial class DelegateInvokeMulticastThunk + public partial class DelegateInvokeMulticastThunk { protected override int ClassCode => 639863471; } - partial class DelegateInvokeInstanceClosedOverGenericMethodThunk + public partial class DelegateInvokeInstanceClosedOverGenericMethodThunk { protected override int ClassCode => -354480633; } - partial class DelegateInvokeObjectArrayThunk + public partial class DelegateInvokeObjectArrayThunk { protected override int ClassCode => 1993292344; } - partial class DelegateGetThunkMethodOverride + public partial class DelegateGetThunkMethodOverride { protected override int ClassCode => -321263379; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs index 55037d70fe810..99834d7cb2363 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs @@ -207,7 +207,7 @@ public override MethodIL EmitIL() codeStream.Emit(ILOpcode.box, emitter.NewToken(boxThisType)); } } - + codeStream.Emit(ILOpcode.call, emitter.NewToken(SystemDelegateType.GetKnownMethod("GetActualTargetFunctionPointer", null))); MethodSignature targetSignature = new MethodSignature(0, 0, Signature.ReturnType, parameters); @@ -346,7 +346,7 @@ public override MethodIL EmitIL() codeStream.EmitLdc(0); codeStream.EmitStLoc(iteratorLocal); - // Loop across every element of the array. + // Loop across every element of the array. ILCodeLabel startOfLoopLabel = emitter.NewCodeLabel(); codeStream.EmitLabel(startOfLoopLabel); @@ -494,7 +494,7 @@ internal DelegateInvokeObjectArrayThunk(DelegateInfo delegateInfo) public override MethodIL EmitIL() { // We will generate the following code: - // + // // object ret; // object[] args = new object[parameterCount]; // args[0] = param0; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.Mangling.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.Mangling.cs index 1c03c18928c7e..012da765943ac 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.Mangling.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.Mangling.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using Internal.TypeSystem; namespace Internal.IL.Stubs diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.Sorting.cs index 3e67c728c743b..0102dfc03b855 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.Sorting.cs @@ -1,15 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using Internal.TypeSystem; -using Debug = System.Diagnostics.Debug; - namespace Internal.IL.Stubs { // Functionality related to deterministic ordering of types - partial class DynamicInvokeMethodThunk + public partial class DynamicInvokeMethodThunk { protected override int ClassCode => -1980933220; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs index 50b446fabc35d..ee50cc4f0565f 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs @@ -1,15 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Reflection.Emit; -using System.Reflection; -using System.Text; - using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; -using Interlocked = System.Threading.Interlocked; namespace Internal.IL.Stubs { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.Sorting.cs index 33b07a8e86f10..b8b935da92f1d 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.Sorting.cs @@ -6,7 +6,7 @@ namespace Internal.IL.Stubs { // Functionality related to deterministic ordering of types - partial class EnumGetHashCodeThunk + internal partial class EnumGetHashCodeThunk { protected override int ClassCode => 261739662; @@ -17,7 +17,7 @@ protected override int CompareToImpl(MethodDesc other, TypeSystemComparer compar } } - partial class EnumEqualsThunk + internal partial class EnumEqualsThunk { protected override int ClassCode => -1774524780; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.cs index dc8fba49876af..f1eb89c48d521 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.cs @@ -12,7 +12,7 @@ namespace Internal.IL.Stubs /// This method prevents boxing of 'this' that would be required before a call to /// the System.Enum's default implementation. /// - internal partial class EnumGetHashCodeThunk : ILStubMethod + internal sealed partial class EnumGetHashCodeThunk : ILStubMethod { private TypeDesc _owningType; private MethodSignature _signature; @@ -103,7 +103,7 @@ public override MethodIL EmitIL() /// This method prevents boxing of 'this' that would be required before a call to /// the System.Enum's default implementation. /// - internal partial class EnumEqualsThunk : ILStubMethod + internal sealed partial class EnumEqualsThunk : ILStubMethod { private TypeDesc _owningType; private MethodSignature _signature; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.Sorting.cs index 66d5142caa287..8a1411a262442 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.Sorting.cs @@ -6,7 +6,7 @@ namespace Internal.IL.Stubs { // Functionality related to deterministic ordering of types - partial class ForwardDelegateCreationThunk + public partial class ForwardDelegateCreationThunk { protected override int ClassCode => 1026039617; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs index fd1e907f84403..3dd0616af51eb 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs @@ -1,11 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using Internal.TypeSystem; using Internal.TypeSystem.Interop; -using Debug = System.Diagnostics.Debug; -using Internal.TypeSystem.Ecma; namespace Internal.IL.Stubs { @@ -18,7 +15,7 @@ public partial class ForwardDelegateCreationThunk : ILStubMethod private readonly MetadataType _delegateType; private readonly InteropStateManager _interopStateManager; private MethodSignature _signature; - + public ForwardDelegateCreationThunk(MetadataType delegateType, TypeDesc owningType, InteropStateManager interopStateManager) { @@ -55,14 +52,11 @@ public override MethodSignature Signature { get { - if (_signature == null) - { - _signature = new MethodSignature(MethodSignatureFlags.Static, 0, + _signature ??= new MethodSignature(MethodSignatureFlags.Static, 0, DelegateType, new TypeDesc[] { Context.GetWellKnownType(WellKnownType.IntPtr) }); - } return _signature; } } @@ -87,7 +81,7 @@ public override string DiagnosticName /// This thunk creates a delegate from a native function pointer /// by first creating a PInvokeDelegateWrapper from the function pointer /// and then creating the delegate from the Invoke method of the wrapper - /// + /// /// Generated IL: /// ldarg 0 /// newobj PInvokeDelegateWrapper.ctor @@ -95,8 +89,8 @@ public override string DiagnosticName /// ldvirtftn PInvokeDelegateWrapper.Invoke /// newobj DelegateType.ctor /// ret - /// - /// Equivalent C# + /// + /// Equivalent C# /// return new DelegateType(new PInvokeDelegateWrapper(functionPointer).Invoke) /// public override MethodIL EmitIL() @@ -116,8 +110,8 @@ public override MethodIL EmitIL() .GetPInvokeDelegateWrapperMethod(PInvokeDelegateWrapperMethodKind.Invoke))); codeStream.Emit(ILOpcode.newobj, emitter.NewToken( - _delegateType.GetMethod(".ctor", - new MethodSignature(MethodSignatureFlags.None, + _delegateType.GetMethod(".ctor", + new MethodSignature(MethodSignatureFlags.None, genericParameterCount: 0, returnType: Context.GetWellKnownType(WellKnownType.Void), parameters: new TypeDesc[] { Context.GetWellKnownType(WellKnownType.Object), diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/GetCanonTypeIntrinsic.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/GetCanonTypeIntrinsic.cs index 5989185359f41..9c44adad0d5fe 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/GetCanonTypeIntrinsic.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/GetCanonTypeIntrinsic.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.Runtime; using Internal.TypeSystem; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ILEmitter.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ILEmitter.cs index bc6985c43e6b6..b6f31e130142e 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ILEmitter.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ILEmitter.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; -using Internal.IL; using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; @@ -521,7 +520,7 @@ internal ILExceptionRegionBuilder() internal int TryLength => _endTryStream.RelativeToAbsoluteOffset(_endTryOffset) - TryOffset; internal int HandlerOffset => _beginHandlerStream.RelativeToAbsoluteOffset(_beginHandlerOffset); internal int HandlerLength => _endHandlerStream.RelativeToAbsoluteOffset(_endHandlerOffset) - HandlerOffset; - + internal bool IsDefined => _beginTryStream != null && _endTryStream != null && _beginHandlerStream != null && _endHandlerStream != null; @@ -542,7 +541,7 @@ public class ILStubMethodIL : MethodIL { private readonly byte[] _ilBytes; private readonly LocalVariableDefinition[] _locals; - private readonly Object[] _tokens; + private readonly object[] _tokens; private readonly MethodDesc _method; private readonly ILExceptionRegion[] _exceptionRegions; private readonly MethodDebugInformation _debugInformation; @@ -550,7 +549,7 @@ public class ILStubMethodIL : MethodIL private const int MaxStackNotSet = -1; private int _maxStack; - public ILStubMethodIL(MethodDesc owningMethod, byte[] ilBytes, LocalVariableDefinition[] locals, Object[] tokens, ILExceptionRegion[] exceptionRegions = null, MethodDebugInformation debugInfo = null) + public ILStubMethodIL(MethodDesc owningMethod, byte[] ilBytes, LocalVariableDefinition[] locals, object[] tokens, ILExceptionRegion[] exceptionRegions = null, MethodDebugInformation debugInfo = null) { _ilBytes = ilBytes; _locals = locals; @@ -558,12 +557,10 @@ public ILStubMethodIL(MethodDesc owningMethod, byte[] ilBytes, LocalVariableDefi _method = owningMethod; _maxStack = MaxStackNotSet; - if (exceptionRegions == null) - exceptionRegions = Array.Empty(); + exceptionRegions ??= Array.Empty(); _exceptionRegions = exceptionRegions; - if (debugInfo == null) - debugInfo = MethodDebugInformation.None; + debugInfo ??= MethodDebugInformation.None; _debugInformation = debugInfo; } @@ -622,7 +619,7 @@ public override LocalVariableDefinition[] GetLocals() { return _locals; } - public override Object GetObject(int token, NotFoundBehavior notFoundBehavior) + public override object GetObject(int token, NotFoundBehavior notFoundBehavior) { return _tokens[(token & 0xFFFFFF) - 1]; } @@ -666,7 +663,7 @@ public class ILEmitter { private ArrayBuilder _codeStreams; private ArrayBuilder _locals; - private ArrayBuilder _tokens; + private ArrayBuilder _tokens; private ArrayBuilder _finallyRegions; public ILEmitter() @@ -680,7 +677,7 @@ public ILCodeStream NewCodeStream() return stream; } - private ILToken NewToken(Object value, int tokenType) + private ILToken NewToken(object value, int tokenType) { Debug.Assert(value != null); _tokens.Add(value); @@ -802,7 +799,7 @@ public MethodIL Link(MethodDesc owningMethod) return result; } - private class EmittedMethodDebugInformation : MethodDebugInformation + private sealed class EmittedMethodDebugInformation : MethodDebugInformation { private readonly ILSequencePoint[] _sequencePoints; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs index 25523f68b100f..7f0a8d2f191a4 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MemoryMarshalIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MemoryMarshalIntrinsics.cs index de2c2712827c5..aaa56db0888c7 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MemoryMarshalIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MemoryMarshalIntrinsics.cs @@ -1,7 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - +#if READYTORUN using ILCompiler; +#endif using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.Mangling.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.Mangling.cs index 868ffc7c7596f..1aeb7468376e6 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.Mangling.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.Mangling.cs @@ -5,7 +5,7 @@ namespace Internal.IL.Stubs { - partial class MethodBaseGetCurrentMethodThunk : IPrefixMangledMethod + internal partial class MethodBaseGetCurrentMethodThunk : IPrefixMangledMethod { MethodDesc IPrefixMangledMethod.BaseMethod { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.Sorting.cs index d3afe93c39660..072225e04798d 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.Sorting.cs @@ -6,7 +6,7 @@ namespace Internal.IL.Stubs { // Functionality related to deterministic ordering of types - partial class MethodBaseGetCurrentMethodThunk + internal partial class MethodBaseGetCurrentMethodThunk { protected override int ClassCode => 1889524798; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs index 82a729dc3eb2d..eaed268049d42 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs @@ -12,7 +12,7 @@ namespace Internal.IL.Stubs /// is to LDTOKEN the method considered "current method" and call into the class library to /// retrieve the associated MethodBase object instance. /// - internal partial class MethodBaseGetCurrentMethodThunk : ILStubMethod + internal sealed partial class MethodBaseGetCurrentMethodThunk : ILStubMethod { public MethodBaseGetCurrentMethodThunk(MethodDesc method) { @@ -90,7 +90,7 @@ public override MethodIL EmitIL() } } - internal class MethodBaseGetCurrentMethodThunkCache + internal sealed class MethodBaseGetCurrentMethodThunkCache { private Unifier _cache; @@ -104,7 +104,7 @@ public MethodDesc GetHelper(MethodDesc currentMethod) return _cache.GetOrCreateValue(currentMethod.GetTypicalMethodDefinition()); } - private class Unifier : LockFreeReaderHashtable + private sealed class Unifier : LockFreeReaderHashtable { protected override int GetKeyHashCode(MethodDesc key) { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeILCodeStreams.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeILCodeStreams.cs index 1ad547dbb468b..2a8aa221ce217 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeILCodeStreams.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeILCodeStreams.cs @@ -22,9 +22,9 @@ public PInvokeILCodeStreams() // store that into the local // - CallsiteSetupCodeStream is used to used to load each previously generated local // and call the actual target native method. - // - ReturnValueMarshallingCodeStream is used to convert the native return value + // - ReturnValueMarshallingCodeStream is used to convert the native return value // to managed one. - // - UnmarshallingCodestream is used to propagate [out] native arguments values to + // - UnmarshallingCodestream is used to propagate [out] native arguments values to // managed ones. // - CleanupCodestream is used to perform a guaranteed cleanup FunctionPointerLoadStream = Emitter.NewCodeStream(); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeILEmitter.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeILEmitter.cs index 9d89ea5314694..42c25c1eee965 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeILEmitter.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeILEmitter.cs @@ -444,7 +444,7 @@ public static MethodIL EmitIL(MethodDesc method, } catch (InvalidProgramException ex) { - Debug.Assert(!String.IsNullOrEmpty(ex.Message)); + Debug.Assert(!string.IsNullOrEmpty(ex.Message)); return MarshalHelpers.EmitExceptionBody(ex.Message, method); } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.Sorting.cs index d3156fbefb2cf..755340991928f 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.Sorting.cs @@ -5,7 +5,7 @@ namespace Internal.IL.Stubs { - partial class PInvokeLazyFixupField + public partial class PInvokeLazyFixupField { protected override int ClassCode => -1784477702; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.Diagnostic.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.Diagnostic.cs index 66be6d9654452..940710e5078c2 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.Diagnostic.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.Diagnostic.cs @@ -1,11 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Internal.TypeSystem; - namespace Internal.IL.Stubs { - partial class PInvokeTargetNativeMethod + public partial class PInvokeTargetNativeMethod { public override string DiagnosticName { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.Mangling.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.Mangling.cs index 0840a5856fa2a..34ec3ed4ec351 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.Mangling.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.Mangling.cs @@ -5,7 +5,7 @@ namespace Internal.IL.Stubs { - partial class PInvokeTargetNativeMethod : IPrefixMangledMethod + public partial class PInvokeTargetNativeMethod : IPrefixMangledMethod { MethodDesc IPrefixMangledMethod.BaseMethod { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.Sorting.cs index da12ad0a8b2dc..40449fc96b97a 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.Sorting.cs @@ -6,7 +6,7 @@ namespace Internal.IL.Stubs { // Functionality related to deterministic ordering of types - partial class PInvokeTargetNativeMethod + public partial class PInvokeTargetNativeMethod { protected internal override int ClassCode => -1626939381; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.cs index 5683eee0429f1..0e3eaeae12e7e 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.cs @@ -14,7 +14,7 @@ public sealed partial class PInvokeTargetNativeMethod : MethodDesc { private readonly MethodDesc _declMethod; private readonly MethodSignature _signature; - + public MethodDesc Target { get diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs index 53af0f37161d9..b8e1a23ca21e5 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs @@ -96,4 +96,3 @@ public static MethodIL EmitIL(MethodDesc method) } } } - diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs index 292e0240c6720..fc28505f84ced 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.Sorting.cs index 0cbb4f7e7c6c3..99365af5d86af 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.Sorting.cs @@ -6,7 +6,7 @@ namespace Internal.IL.Stubs { // Functionality related to deterministic ordering of types - partial class StructMarshallingThunk + public partial class StructMarshallingThunk { protected override int ClassCode => 340834018; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs index 2751290f0c91e..f8025e77c2087 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs @@ -90,7 +90,7 @@ public override MethodSignature Signature }; break; default: - System.Diagnostics.Debug.Fail("Unexpected Struct marshalling thunk type"); + Debug.Fail("Unexpected Struct marshalling thunk type"); break; } _signature = new MethodSignature(MethodSignatureFlags.Static, 0, Context.GetWellKnownType(WellKnownType.Void), parameters); @@ -112,7 +112,7 @@ private string NamePrefix case StructMarshallingThunkType.Cleanup: return "Cleanup"; default: - System.Diagnostics.Debug.Fail("Unexpected Struct marshalling thunk type"); + Debug.Fail("Unexpected Struct marshalling thunk type"); return string.Empty; } } @@ -148,7 +148,7 @@ private Marshaller[] InitializeMarshallers() Marshaller[] marshallers = new Marshaller[numInstanceFields]; - PInvokeFlags flags = new PInvokeFlags(); + PInvokeFlags flags = default(PInvokeFlags); if (ManagedType.PInvokeStringFormat == PInvokeStringFormat.UnicodeClass || ManagedType.PInvokeStringFormat == PInvokeStringFormat.AutoClass) { flags.CharSet = CharSet.Unicode; @@ -203,17 +203,17 @@ private MethodIL EmitMarshallingIL(PInvokeILCodeStreams pInvokeILCodeStreams) } bool notEmpty = nativeEnumerator.MoveNext(); - Debug.Assert(notEmpty == true); + Debug.Assert(notEmpty); var nativeField = nativeEnumerator.Current; Debug.Assert(nativeField != null); bool isInlineArray = nativeField.FieldType is InlineArrayType; // - // Field marshallers expects the value of the fields to be + // Field marshallers expects the value of the fields to be // loaded on the stack. We load the value on the stack // before calling the marshallers. // Only exception is ByValArray marshallers. Since they can - // only be used for field marshalling, they load/store values + // only be used for field marshalling, they load/store values // directly from arguments. // @@ -270,7 +270,7 @@ private MethodIL EmitCleanupIL(PInvokeILCodeStreams pInvokeILCodeStreams) } bool notEmpty = nativeEnumerator.MoveNext(); - Debug.Assert(notEmpty == true); + Debug.Assert(notEmpty); var nativeField = nativeEnumerator.Current; Debug.Assert(nativeField != null); @@ -310,7 +310,7 @@ public override MethodIL EmitIL() } catch (InvalidProgramException ex) { - Debug.Assert(!String.IsNullOrEmpty(ex.Message)); + Debug.Assert(!string.IsNullOrEmpty(ex.Message)); return MarshalHelpers.EmitExceptionBody(ex.Message, this); } } @@ -318,7 +318,7 @@ public override MethodIL EmitIL() /// /// Loads the value of field of a struct at argument index argIndex to stack /// - private void LoadFieldValueFromArg(int argIndex, FieldDesc field, PInvokeILCodeStreams pInvokeILCodeStreams) + private static void LoadFieldValueFromArg(int argIndex, FieldDesc field, PInvokeILCodeStreams pInvokeILCodeStreams) { ILCodeStream stream = pInvokeILCodeStreams.MarshallingCodeStream; ILEmitter emitter = pInvokeILCodeStreams.Emitter; @@ -326,7 +326,7 @@ private void LoadFieldValueFromArg(int argIndex, FieldDesc field, PInvokeILCodeS stream.Emit(ILOpcode.ldfld, emitter.NewToken(field)); } - private void StoreFieldValueFromArg(int argIndex, FieldDesc field, PInvokeILCodeStreams pInvokeILCodeStreams) + private static void StoreFieldValueFromArg(int argIndex, FieldDesc field, PInvokeILCodeStreams pInvokeILCodeStreams) { ILCodeStream stream = pInvokeILCodeStreams.MarshallingCodeStream; ILEmitter emitter = pInvokeILCodeStreams.Emitter; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.Sorting.cs index c99a3ff3b40fa..ceb658e3bd895 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.Sorting.cs @@ -8,7 +8,7 @@ namespace Internal.IL.Stubs { // Functionality related to deterministic ordering of types - partial class TypeGetTypeMethodThunk + internal partial class TypeGetTypeMethodThunk { protected override int ClassCode => -949164050; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs index 7e7a9133b13c0..48db579f5ea5a 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs @@ -12,7 +12,7 @@ namespace Internal.IL.Stubs /// the calling assembly for a matching type if the type name supplied by the user code was not assembly qualified. /// This thunk calls a helper method, passing it a string for what should be considered the "calling assembly". /// - internal partial class TypeGetTypeMethodThunk : ILStubMethod + internal sealed partial class TypeGetTypeMethodThunk : ILStubMethod { private readonly MethodDesc _helperMethod; @@ -104,7 +104,7 @@ public override MethodIL EmitIL() } } - internal class TypeGetTypeMethodThunkCache + internal sealed class TypeGetTypeMethodThunkCache { private TypeDesc _owningTypeForThunks; private Unifier _cache; @@ -132,7 +132,7 @@ public Key(string defaultAssemblyName, MethodDesc getTypeOverload) } } - private class Unifier : LockFreeReaderHashtable + private sealed class Unifier : LockFreeReaderHashtable { private TypeGetTypeMethodThunkCache _parent; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/UnsafeIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/UnsafeIntrinsics.cs index c371ec782fec6..f25671773490b 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/UnsafeIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/UnsafeIntrinsics.cs @@ -81,7 +81,7 @@ public static MethodIL EmitIL(MethodDesc method) case "IsNullRef": return new ILStubMethodIL(method, new byte[] { - (byte)ILOpcode.ldarg_0, + (byte)ILOpcode.ldarg_0, (byte)ILOpcode.ldc_i4_0, (byte)ILOpcode.conv_u, (byte)ILOpcode.prefix1, unchecked((byte)ILOpcode.ceq), (byte)ILOpcode.ret }, Array.Empty(), null); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.Sorting.cs index e12b3bc41567f..2a650a278e24a 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.Sorting.cs @@ -5,7 +5,7 @@ namespace Internal.IL.Stubs { - partial class ValueTypeGetFieldHelperMethodOverride + public partial class ValueTypeGetFieldHelperMethodOverride { protected override int ClassCode => 2036839816; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs index 76c9184d4e637..9bb60e317e249 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs @@ -71,7 +71,7 @@ public override MethodIL EmitIL() var switchStream = emitter.NewCodeStream(); var getFieldStream = emitter.NewCodeStream(); - ArrayBuilder fieldGetters = new ArrayBuilder(); + ArrayBuilder fieldGetters = default(ArrayBuilder); foreach (FieldDesc field in owningType.GetFields()) { if (field.IsStatic) @@ -120,7 +120,7 @@ public override MethodIL EmitIL() } switchStream.EmitLdc(fieldGetters.Count); - + switchStream.Emit(ILOpcode.ret); return emitter.Link(this); diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/FieldDesc.Interop.cs b/src/coreclr/tools/Common/TypeSystem/Interop/FieldDesc.Interop.cs index ad5a51232d731..e12791ba2d7c5 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/FieldDesc.Interop.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/FieldDesc.Interop.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem { - partial class FieldDesc + public partial class FieldDesc { /// /// Returns description of how the field should be marshalled to native code. @@ -14,7 +14,7 @@ public virtual MarshalAsDescriptor GetMarshalAsDescriptor() } } - partial class FieldForInstantiatedType + public partial class FieldForInstantiatedType { public override MarshalAsDescriptor GetMarshalAsDescriptor() { diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.Sorting.cs index a6d57faa45a4e..ca637423c2cb2 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.Sorting.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem.Interop { // Functionality related to deterministic ordering of types - partial class InlineArrayType + internal partial class InlineArrayType { protected override int ClassCode => 226817075; @@ -18,7 +18,7 @@ protected override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer return comparer.Compare(ElementType, otherType.ElementType); } - partial class InlineArrayMethod + private partial class InlineArrayMethod { protected override int ClassCode => -1303220581; @@ -34,7 +34,7 @@ protected override int CompareToImpl(MethodDesc other, TypeSystemComparer compar } } - partial class InlineArrayField + private partial class InlineArrayField { protected override int ClassCode => 1542668652; diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs index 51ac01f9a2fb6..512cad4be34ef 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs @@ -173,7 +173,7 @@ public InlineArrayType(ModuleDesc owningModule, MetadataType elementType, uint l public override ClassLayoutMetadata GetClassLayout() { - ClassLayoutMetadata result = new ClassLayoutMetadata(); + ClassLayoutMetadata result = default(ClassLayoutMetadata); result.PackingSize = 0; result.Size = checked((int)Length * ElementType.GetElementSize().AsInt); return result; @@ -329,7 +329,7 @@ public override string Name { return "get_Item"; } - else + else { return "set_Item"; } @@ -352,9 +352,9 @@ public override MethodSignature Signature { if (_kind == InlineArrayMethodKind.Getter) { - _signature = new MethodSignature(MethodSignatureFlags.None, - genericParameterCount: 0, - returnType: _owningType.ElementType, + _signature = new MethodSignature(MethodSignatureFlags.None, + genericParameterCount: 0, + returnType: _owningType.ElementType, parameters: new TypeDesc[] { Context.GetWellKnownType(WellKnownType.Int32) }); } else @@ -373,10 +373,7 @@ public override MethodIL EmitIL() { var emitter = new ILEmitter(); var codeStream = emitter.NewCodeStream(); - var lIntermediate = emitter.NewCodeLabel(); - var lCheck = emitter.NewCodeLabel(); - var lValid = emitter.NewCodeLabel(); - var vFlag = emitter.NewLocal(Context.GetWellKnownType(WellKnownType.Boolean)); + _ = emitter.NewLocal(Context.GetWellKnownType(WellKnownType.Boolean)); var elementType = _owningType.ElementType; // Getter: diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.Aot.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.Aot.cs index b047f29e9ec64..29abb9313ea30 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.Aot.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.Aot.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.IL; using Internal.IL.Stubs; @@ -51,7 +49,7 @@ public static bool IsStructMarshallingRequired(TypeDesc typeDesc) internal static TypeDesc GetNativeMethodParameterType(TypeDesc type, MarshalAsDescriptor marshalAs, InteropStateManager interopStateManager, bool isReturn, bool isAnsi) { MarshallerKind elementMarshallerKind; - MarshallerKind marshallerKind = MarshalHelpers.GetMarshallerKind(type, + MarshallerKind marshallerKind = GetMarshallerKind(type, null, /* parameterIndex */ null, /* customModifierData */ marshalAs, @@ -70,7 +68,7 @@ internal static TypeDesc GetNativeMethodParameterType(TypeDesc type, MarshalAsDe internal static TypeDesc GetNativeStructFieldType(TypeDesc type, MarshalAsDescriptor marshalAs, InteropStateManager interopStateManager, bool isAnsi) { MarshallerKind elementMarshallerKind; - MarshallerKind marshallerKind = MarshalHelpers.GetMarshallerKind(type, + MarshallerKind marshallerKind = GetMarshallerKind(type, null, /* parameterIndex */ null, /* customModifierData */ marshalAs, diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs index eac31ec115d9a..ebcaee6ddfe55 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs @@ -2,9 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using Internal.IL; using Debug = System.Diagnostics.Debug; -using Internal.IL.Stubs; using Internal.TypeSystem.Ecma; namespace Internal.TypeSystem.Interop diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalUtils.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalUtils.cs index 33c609ee23b80..fcc954bc8f984 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalUtils.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalUtils.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace Internal.TypeSystem.Interop { public static class MarshalUtils diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.Aot.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.Aot.cs index c001032f31291..f35e028ff49fb 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.Aot.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.Aot.cs @@ -3,7 +3,6 @@ using System; using System.Buffers.Binary; -using System.Runtime.InteropServices; using Internal.IL.Stubs; using Internal.IL; @@ -14,7 +13,7 @@ namespace Internal.TypeSystem.Interop { - partial class Marshaller + internal partial class Marshaller { protected static Marshaller CreateMarshaller(MarshallerKind kind) { @@ -104,7 +103,7 @@ protected static Marshaller CreateMarshaller(MarshallerKind kind) } } - class AnsiCharArrayMarshaller : ArrayMarshaller + internal sealed class AnsiCharArrayMarshaller : ArrayMarshaller { protected override void AllocManagedToNative(ILCodeStream codeStream) { @@ -141,7 +140,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) } } - class AnsiCharMarshaller : Marshaller + internal sealed class AnsiCharMarshaller : Marshaller { protected override void AllocAndTransformManagedToNative(ILCodeStream codeStream) { @@ -166,7 +165,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) } } - class StringBuilderMarshaller : Marshaller + internal sealed class StringBuilderMarshaller : Marshaller { private bool _isAnsi; public StringBuilderMarshaller(bool isAnsi) @@ -250,7 +249,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) } } - class HandleRefMarshaller : Marshaller + internal sealed class HandleRefMarshaller : Marshaller { protected override void AllocAndTransformManagedToNative(ILCodeStream codeStream) { @@ -277,7 +276,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) } } - class StructMarshaller : Marshaller + internal sealed class StructMarshaller : Marshaller { protected override void AllocManagedToNative(ILCodeStream codeStream) { @@ -315,7 +314,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) } } - class ByValArrayMarshaller : ArrayMarshaller + internal class ByValArrayMarshaller : ArrayMarshaller { protected FieldDesc _managedField; protected FieldDesc _nativeField; @@ -542,11 +541,10 @@ protected override void EmitMarshalFieldNativeToManaged() } } - abstract class ByValStringMarshaller : ByValArrayMarshaller + internal abstract class ByValStringMarshaller : ByValArrayMarshaller { protected override void EmitElementCount(ILCodeStream codeStream, MarshalDirection direction) { - ILEmitter emitter = _ilCodeStreams.Emitter; if (MarshalAsDescriptor == null || !MarshalAsDescriptor.SizeConst.HasValue) { throw new InvalidProgramException("SizeConst is required for ByValString."); @@ -608,7 +606,7 @@ protected override void EmitMarshalFieldNativeToManaged() } } - class ByValAnsiStringMarshaller : ByValStringMarshaller + internal sealed class ByValAnsiStringMarshaller : ByValStringMarshaller { protected override bool IsAnsi { @@ -629,7 +627,7 @@ protected override MethodDesc GetNativeToManagedHelper() } } - class ByValUnicodeStringMarshaller : ByValStringMarshaller + internal sealed class ByValUnicodeStringMarshaller : ByValStringMarshaller { protected override bool IsAnsi { @@ -650,7 +648,7 @@ protected override MethodDesc GetNativeToManagedHelper() } } - class LayoutClassMarshaler : Marshaller + internal sealed class LayoutClassMarshaler : Marshaller { protected override void AllocManagedToNative(ILCodeStream codeStream) { @@ -710,7 +708,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) } } - class LayoutClassPtrMarshaller : Marshaller + internal sealed class LayoutClassPtrMarshaller : Marshaller { protected override void AllocManagedToNative(ILCodeStream codeStream) { @@ -801,7 +799,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) } } - class AsAnyMarshaller : Marshaller + internal sealed class AsAnyMarshaller : Marshaller { // This flag affects encoding of string, StringBuilder and Char array marshalling. // It does not affect LayoutClass marshalling. @@ -893,7 +891,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) } } - class ComInterfaceMarshaller : Marshaller + internal sealed class ComInterfaceMarshaller : Marshaller { protected override void AllocAndTransformManagedToNative(ILCodeStream codeStream) { @@ -965,7 +963,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) } } - class AnsiBSTRStringMarshaller : Marshaller + internal sealed class AnsiBSTRStringMarshaller : Marshaller { internal override bool CleanupRequired => true; @@ -998,7 +996,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) } } - class BSTRStringMarshaller : Marshaller + internal sealed class BSTRStringMarshaller : Marshaller { internal override bool CleanupRequired => true; @@ -1031,7 +1029,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) } } - class OleDateTimeMarshaller : Marshaller + internal sealed class OleDateTimeMarshaller : Marshaller { protected override void TransformManagedToNative(ILCodeStream codeStream) { @@ -1056,7 +1054,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) } } - class OleCurrencyMarshaller : Marshaller + internal sealed class OleCurrencyMarshaller : Marshaller { protected override void TransformManagedToNative(ILCodeStream codeStream) { @@ -1081,7 +1079,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) } } - class FailedTypeLoadMarshaller : Marshaller + internal sealed class FailedTypeLoadMarshaller : Marshaller { protected override void TransformManagedToNative(ILCodeStream codeStream) { @@ -1094,7 +1092,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) } } - class VariantMarshaller : Marshaller + internal sealed class VariantMarshaller : Marshaller { protected override void AllocManagedToNative(ILCodeStream codeStream) { @@ -1150,8 +1148,9 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); } } - - class CustomTypeMarshaller : Marshaller +#pragma warning disable CA1852 + internal class CustomTypeMarshaller : Marshaller +#pragma warning restore CA1852 { private ILLocalVariable MarshallerLocalVariable = (ILLocalVariable)(-1); @@ -1283,7 +1282,7 @@ protected void EmitCleanUpNativeData(ILCodeStream codeStream) } } - class BlittableValueClassByRefReturn : Marshaller + internal sealed class BlittableValueClassByRefReturn : Marshaller { protected override void SetupArgumentsForReturnValueMarshalling() { diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.cs index 06d839390d1f8..a7d62d1c422f2 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.cs @@ -20,7 +20,7 @@ public enum MarshalDirection // Each type of marshaller knows how to generate the marshalling code for the argument it marshals. // Marshallers contain method related marshalling information (which is common to all the Marshallers) // and also argument specific marshalling information. - abstract partial class Marshaller + internal abstract partial class Marshaller { #region Instance state information public TypeSystemContext Context; @@ -111,7 +111,7 @@ internal virtual bool CleanupRequired protected Home _nativeHome; #endregion - enum HomeType + private enum HomeType { Arg, Local, @@ -122,7 +122,7 @@ enum HomeType /// /// Abstraction for handling by-ref and non-by-ref locals/arguments /// - internal class Home + internal sealed class Home { public Home(ILLocalVariable var, TypeDesc type, bool isByRef) { @@ -203,10 +203,10 @@ public void StoreValue(ILCodeStream stream) } } - HomeType _homeType; - TypeDesc _type; - ILLocalVariable _var; - int _argIndex; + private HomeType _homeType; + private TypeDesc _type; + private ILLocalVariable _var; + private int _argIndex; } #region Creation of marshallers @@ -489,7 +489,6 @@ protected virtual void EmitReverseFieldMarshallingIL() protected virtual void EmitMarshalReturnValueManagedToNative() { - ILEmitter emitter = _ilCodeStreams.Emitter; SetupArgumentsForReturnValueMarshalling(); StoreNativeValue(_ilCodeStreams.ReturnValueMarshallingCodeStream); @@ -757,7 +756,6 @@ protected virtual void EmitCleanupManaged(ILCodeStream codeStream) protected virtual void EmitMarshalReturnValueNativeToManaged() { - ILEmitter emitter = _ilCodeStreams.Emitter; SetupArgumentsForReturnValueMarshalling(); StoreManagedValue(_ilCodeStreams.ReturnValueMarshallingCodeStream); @@ -805,7 +803,6 @@ protected virtual void EmitMarshalArgumentNativeToManaged() protected virtual void EmitMarshalElementManagedToNative() { - ILEmitter emitter = _ilCodeStreams.Emitter; ILCodeStream codeStream = _ilCodeStreams.MarshallingCodeStream; Debug.Assert(codeStream != null); @@ -821,7 +818,6 @@ protected virtual void EmitMarshalElementManagedToNative() protected virtual void EmitMarshalElementNativeToManaged() { - ILEmitter emitter = _ilCodeStreams.Emitter; ILCodeStream codeStream = _ilCodeStreams.MarshallingCodeStream; Debug.Assert(codeStream != null); @@ -836,7 +832,6 @@ protected virtual void EmitMarshalElementNativeToManaged() protected virtual void EmitMarshalFieldManagedToNative() { - ILEmitter emitter = _ilCodeStreams.Emitter; ILCodeStream marshallingCodeStream = _ilCodeStreams.MarshallingCodeStream; SetupArgumentsForFieldMarshalling(); @@ -854,7 +849,6 @@ protected virtual void EmitMarshalFieldManagedToNative() protected virtual void EmitMarshalFieldNativeToManaged() { - ILEmitter emitter = _ilCodeStreams.Emitter; ILCodeStream codeStream = _ilCodeStreams.MarshallingCodeStream; SetupArgumentsForFieldMarshalling(); @@ -879,7 +873,7 @@ internal virtual void EmitElementCleanup(ILCodeStream codestream, ILEmitter emit } } - class NotSupportedMarshaller : Marshaller + internal sealed class NotSupportedMarshaller : Marshaller { public override void EmitMarshallingIL(PInvokeILCodeStreams pInvokeILCodeStreams) { @@ -887,7 +881,7 @@ public override void EmitMarshallingIL(PInvokeILCodeStreams pInvokeILCodeStreams } } - class VoidReturnMarshaller : Marshaller + internal sealed class VoidReturnMarshaller : Marshaller { protected override void EmitMarshalReturnValueManagedToNative() { @@ -901,7 +895,7 @@ public override void LoadReturnValue(ILCodeStream codeStream) } } - class BlittableValueMarshaller : Marshaller + internal sealed class BlittableValueMarshaller : Marshaller { protected override void EmitMarshalArgumentManagedToNative() { @@ -944,7 +938,7 @@ protected override void EmitMarshalArgumentNativeToManaged() } } - class BlittableStructPtrMarshaller : Marshaller + internal sealed class BlittableStructPtrMarshaller : Marshaller { protected override void TransformManagedToNative(ILCodeStream codeStream) { @@ -967,7 +961,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) } } - class ArrayMarshaller : Marshaller + internal class ArrayMarshaller : Marshaller { private Marshaller _elementMarshaller; @@ -1039,8 +1033,8 @@ protected virtual void EmitElementCount(ILCodeStream codeStream, MarshalDirectio else { - uint? sizeParamIndex = MarshalAsDescriptor != null ? MarshalAsDescriptor.SizeParamIndex : null; - uint? sizeConst = MarshalAsDescriptor != null ? MarshalAsDescriptor.SizeConst : null; + uint? sizeParamIndex = MarshalAsDescriptor?.SizeParamIndex; + uint? sizeConst = MarshalAsDescriptor?.SizeConst; if (sizeConst.HasValue) { @@ -1350,7 +1344,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) } } - class BlittableArrayMarshaller : ArrayMarshaller + internal sealed class BlittableArrayMarshaller : ArrayMarshaller { protected override void AllocAndTransformManagedToNative(ILCodeStream codeStream) { @@ -1419,7 +1413,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) } } - class BooleanMarshaller : Marshaller + internal sealed class BooleanMarshaller : Marshaller { private int _trueValue; public BooleanMarshaller(int trueValue = 1) @@ -1467,7 +1461,7 @@ protected override void AllocAndTransformNativeToManaged(ILCodeStream codeStream } } - class UnicodeStringMarshaller : Marshaller + internal sealed class UnicodeStringMarshaller : Marshaller { private bool ShouldBePinned { @@ -1587,7 +1581,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) } } - class AnsiStringMarshaller : Marshaller + internal sealed class AnsiStringMarshaller : Marshaller { internal override bool CleanupRequired @@ -1648,11 +1642,11 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) } } - class UTF8StringMarshaller : Marshaller + internal sealed class UTF8StringMarshaller : Marshaller { private const int LocalBufferLength = 0x100; - private ILLocalVariable? _marshallerInstance = null; + private ILLocalVariable? _marshallerInstance; private MetadataType Marshaller => Context.SystemModule.GetKnownType("System.Runtime.InteropServices.Marshalling", "Utf8StringMarshaller"); @@ -1680,8 +1674,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) { TypeDesc marshallerIn = MarshallerIn; - if (_marshallerInstance == null) - _marshallerInstance = emitter.NewLocal(marshallerIn); + _marshallerInstance ??= emitter.NewLocal(marshallerIn); var vBuffer = emitter.NewLocal(Context.GetWellKnownType(WellKnownType.IntPtr)); codeStream.EmitLdc(LocalBufferLength); @@ -1744,7 +1737,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) } } - class SafeHandleMarshaller : Marshaller + internal sealed class SafeHandleMarshaller : Marshaller { private void AllocSafeHandle(ILCodeStream codeStream) { @@ -1787,7 +1780,6 @@ protected override void EmitMarshalArgumentManagedToNative() ILEmitter emitter = _ilCodeStreams.Emitter; ILCodeStream marshallingCodeStream = _ilCodeStreams.MarshallingCodeStream; ILCodeStream callsiteCodeStream = _ilCodeStreams.CallsiteSetupCodeStream; - ILCodeStream unmarshallingCodeStream = _ilCodeStreams.UnmarshallingCodestream; ILCodeStream cleanupCodeStream = _ilCodeStreams.CleanupCodeStream; SetupArguments(); @@ -1905,7 +1897,7 @@ protected override void EmitMarshalFieldNativeToManaged() } } - class DelegateMarshaller : Marshaller + internal sealed class DelegateMarshaller : Marshaller { protected override void AllocAndTransformManagedToNative(ILCodeStream codeStream) { diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshallerKind.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshallerKind.cs index 65f9e979e76f2..b1ff401809e28 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshallerKind.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshallerKind.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem.Interop { - enum MarshallerKind + internal enum MarshallerKind { Unknown, BlittableValue, diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.Mangling.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.Mangling.cs index fe3edc156824a..c209aebdec552 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.Mangling.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.Mangling.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem.Interop { - partial class NativeStructType : IPrefixMangledType + public partial class NativeStructType : IPrefixMangledType { TypeDesc IPrefixMangledType.BaseType => ManagedStructType; diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.Sorting.cs index e66dc55d975c0..1796d26e60782 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.Sorting.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem.Interop { // Functionality related to deterministic ordering of types - partial class NativeStructType + public partial class NativeStructType { protected override int ClassCode => -377751537; @@ -13,7 +13,7 @@ protected override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer return comparer.Compare(ManagedStructType, ((NativeStructType)other).ManagedStructType); } - partial class NativeStructField + private sealed partial class NativeStructField { protected override int ClassCode => 1580219745; diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs index 477d5c8168b54..9f5ee9edcb96f 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs @@ -161,7 +161,7 @@ public FieldDesc[] Fields } [ThreadStatic] - static Stack s_typesBeingLookedAt; + private static Stack s_typesBeingLookedAt; public NativeStructType(ModuleDesc owningModule, MetadataType managedStructType, InteropStateManager interopStateManager) { @@ -190,7 +190,6 @@ public NativeStructType(ModuleDesc owningModule, MetadataType managedStructType, private void CalculateFields() { - bool isSequential = ManagedStructType.IsSequentialLayout; bool isAnsi = ManagedStructType.PInvokeStringFormat == PInvokeStringFormat.AnsiClass; int numFields = 0; diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.Mangling.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.Mangling.cs index ab66c754f58b0..9ebfc462f9655 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.Mangling.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.Mangling.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem.Interop { - partial class PInvokeDelegateWrapper : IPrefixMangledType + public partial class PInvokeDelegateWrapper : IPrefixMangledType { TypeDesc IPrefixMangledType.BaseType { diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.Sorting.cs index c62bc7675e5af..0611936fca419 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.Sorting.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem.Interop { // Functionality related to deterministic ordering of types - partial class PInvokeDelegateWrapper + public partial class PInvokeDelegateWrapper { protected override int ClassCode => -262930217; diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs index dcc2fbff41c06..c757764156600 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using Internal.IL; using Internal.IL.Stubs; using Debug = System.Diagnostics.Debug; using System.Threading; @@ -154,7 +153,7 @@ public PInvokeDelegateWrapper(ModuleDesc owningModule, MetadataType delegateType Debug.Assert(delegateType.IsDelegate); Module = owningModule; - DelegateType = delegateType; + DelegateType = delegateType; _interopStateManager = interopStateManager; } @@ -238,7 +237,7 @@ private void InitializeMethods() { MethodDesc[] methods = new MethodDesc[] { new PInvokeDelegateWrapperConstructor(this), // Constructor - new DelegateMarshallingMethodThunk(DelegateType, this, _interopStateManager, + new DelegateMarshallingMethodThunk(DelegateType, this, _interopStateManager, DelegateMarshallingMethodThunkKind.ForwardNativeFunctionWrapper) // a forward marshalling instance method }; diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.Sorting.cs index 5fe9290213b2f..d5b75a170e379 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.Sorting.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem.Interop { // Functionality related to deterministic ordering of methods - partial class PInvokeDelegateWrapperConstructor + public partial class PInvokeDelegateWrapperConstructor { protected override int ClassCode => 1000342011; diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.cs index 2e138f6098c7f..10727fac2b4b8 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.cs @@ -1,12 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; using Internal.IL; using Internal.IL.Stubs; -using Debug = System.Diagnostics.Debug; -using System.Threading; namespace Internal.TypeSystem.Interop { @@ -46,15 +42,12 @@ public override MethodSignature Signature { get { - if (_signature == null) - { - _signature = new MethodSignature(MethodSignatureFlags.None, + _signature ??= new MethodSignature(MethodSignatureFlags.None, genericParameterCount: 0, returnType: Context.GetWellKnownType(WellKnownType.Void), parameters: new TypeDesc[] { Context.GetWellKnownType(WellKnownType.IntPtr) }); - } return _signature; } } diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/InteropStateManager.cs b/src/coreclr/tools/Common/TypeSystem/Interop/InteropStateManager.cs index f149f08dc449e..f8a3ea3964066 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/InteropStateManager.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/InteropStateManager.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using Internal.IL.Stubs; using Internal.TypeSystem.Interop; using Debug = System.Diagnostics.Debug; @@ -195,7 +194,7 @@ public MethodDesc GetPInvokeCalliStub(MethodSignature signature, ModuleDesc modu return _pInvokeCalliHashtable.GetOrCreateValue(new CalliMarshallingMethodThunkKey(normalizedSignatureBuilder.ToSignature(), MarshalHelpers.IsRuntimeMarshallingEnabled(moduleContext))); } - private class NativeStructTypeHashtable : LockFreeReaderHashtable + private sealed class NativeStructTypeHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(MetadataType key) { @@ -209,12 +208,12 @@ protected override int GetValueHashCode(NativeStructType value) protected override bool CompareKeyToValue(MetadataType key, NativeStructType value) { - return Object.ReferenceEquals(key, value.ManagedStructType); + return ReferenceEquals(key, value.ManagedStructType); } protected override bool CompareValueToValue(NativeStructType value1, NativeStructType value2) { - return Object.ReferenceEquals(value1.ManagedStructType, value2.ManagedStructType); + return ReferenceEquals(value1.ManagedStructType, value2.ManagedStructType); } protected override NativeStructType CreateValueFromKey(MetadataType key) @@ -244,7 +243,7 @@ public StructMarshallingThunkKey(MetadataType type, StructMarshallingThunkType t } } - private class StructMarshallingThunkHashTable : LockFreeReaderHashtable + private sealed class StructMarshallingThunkHashTable : LockFreeReaderHashtable { protected override int GetKeyHashCode(StructMarshallingThunkKey key) { @@ -258,13 +257,13 @@ protected override int GetValueHashCode(StructMarshallingThunk value) protected override bool CompareKeyToValue(StructMarshallingThunkKey key, StructMarshallingThunk value) { - return Object.ReferenceEquals(key.ManagedType, value.ManagedType) && + return ReferenceEquals(key.ManagedType, value.ManagedType) && key.ThunkType == value.ThunkType; } protected override bool CompareValueToValue(StructMarshallingThunk value1, StructMarshallingThunk value2) { - return Object.ReferenceEquals(value1.ManagedType, value2.ManagedType) && + return ReferenceEquals(value1.ManagedType, value2.ManagedType) && value1.ThunkType == value2.ThunkType; } @@ -283,7 +282,7 @@ public StructMarshallingThunkHashTable(InteropStateManager interopStateManager, } } - private class InlineArrayHashTable : LockFreeReaderHashtable + private sealed class InlineArrayHashTable : LockFreeReaderHashtable { protected override int GetKeyHashCode(InlineArrayCandidate key) { @@ -297,13 +296,13 @@ protected override int GetValueHashCode(InlineArrayType value) protected override bool CompareKeyToValue(InlineArrayCandidate key, InlineArrayType value) { - return Object.ReferenceEquals(key.ElementType, value.ElementType) && + return ReferenceEquals(key.ElementType, value.ElementType) && key.Length == value.Length; } protected override bool CompareValueToValue(InlineArrayType value1, InlineArrayType value2) { - return Object.ReferenceEquals(value1.ElementType, value2.ElementType) && + return ReferenceEquals(value1.ElementType, value2.ElementType) && value1.Length == value2.Length; } @@ -333,7 +332,7 @@ public DelegateMarshallingStubHashtableKey(MetadataType type, DelegateMarshallin Kind = kind; } } - private class DelegateMarshallingStubHashtable : LockFreeReaderHashtable + private sealed class DelegateMarshallingStubHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(DelegateMarshallingStubHashtableKey key) { @@ -347,13 +346,13 @@ protected override int GetValueHashCode(DelegateMarshallingMethodThunk value) protected override bool CompareKeyToValue(DelegateMarshallingStubHashtableKey key, DelegateMarshallingMethodThunk value) { - return Object.ReferenceEquals(key.DelegateType, value.DelegateType) && + return ReferenceEquals(key.DelegateType, value.DelegateType) && key.Kind== value.Kind; } protected override bool CompareValueToValue(DelegateMarshallingMethodThunk value1, DelegateMarshallingMethodThunk value2) { - return Object.ReferenceEquals(value1.DelegateType, value2.DelegateType) && + return ReferenceEquals(value1.DelegateType, value2.DelegateType) && value1.Kind== value2.Kind; } @@ -373,7 +372,7 @@ public DelegateMarshallingStubHashtable(InteropStateManager interopStateManager, } } - private class ForwardDelegateCreationStubHashtable : LockFreeReaderHashtable + private sealed class ForwardDelegateCreationStubHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(MetadataType key) { @@ -387,12 +386,12 @@ protected override int GetValueHashCode(ForwardDelegateCreationThunk value) protected override bool CompareKeyToValue(MetadataType key, ForwardDelegateCreationThunk value) { - return Object.ReferenceEquals(key, value.DelegateType); + return ReferenceEquals(key, value.DelegateType); } protected override bool CompareValueToValue(ForwardDelegateCreationThunk value1, ForwardDelegateCreationThunk value2) { - return Object.ReferenceEquals(value1.DelegateType, value2.DelegateType); + return ReferenceEquals(value1.DelegateType, value2.DelegateType); } protected override ForwardDelegateCreationThunk CreateValueFromKey(MetadataType key) @@ -410,7 +409,7 @@ public ForwardDelegateCreationStubHashtable(InteropStateManager interopStateMana } } - private class PInvokeDelegateWrapperHashtable : LockFreeReaderHashtable + private sealed class PInvokeDelegateWrapperHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(MetadataType key) { @@ -424,12 +423,12 @@ protected override int GetValueHashCode(PInvokeDelegateWrapper value) protected override bool CompareKeyToValue(MetadataType key, PInvokeDelegateWrapper value) { - return Object.ReferenceEquals(key, value.DelegateType); + return ReferenceEquals(key, value.DelegateType); } protected override bool CompareValueToValue(PInvokeDelegateWrapper value1, PInvokeDelegateWrapper value2) { - return Object.ReferenceEquals(value1.DelegateType, value2.DelegateType); + return ReferenceEquals(value1.DelegateType, value2.DelegateType); } protected override PInvokeDelegateWrapper CreateValueFromKey(MetadataType key) @@ -447,7 +446,7 @@ public PInvokeDelegateWrapperHashtable(InteropStateManager interopStateManager, } } - private class PInvokeLazyFixupFieldHashtable : LockFreeReaderHashtable + private sealed class PInvokeLazyFixupFieldHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(MethodDesc key) { @@ -484,7 +483,7 @@ public PInvokeLazyFixupFieldHashtable(DefType owningType) private readonly record struct CalliMarshallingMethodThunkKey(MethodSignature Signature, bool RuntimeMarshallingEnabled); - private class PInvokeCalliHashtable : LockFreeReaderHashtable + private sealed class PInvokeCalliHashtable : LockFreeReaderHashtable { private readonly InteropStateManager _interopStateManager; private readonly TypeDesc _owningType; diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/InteropTypes.cs b/src/coreclr/tools/Common/TypeSystem/Interop/InteropTypes.cs index f69879a10ee15..8bbdb13630bfe 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/InteropTypes.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/InteropTypes.cs @@ -3,8 +3,6 @@ using Internal.IL; -using Debug = System.Diagnostics.Debug; - namespace Internal.TypeSystem.Interop { public static class InteropTypes diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/MarshalAsDescriptor.cs b/src/coreclr/tools/Common/TypeSystem/Interop/MarshalAsDescriptor.cs index c76e2cf469350..39ecc973755e1 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/MarshalAsDescriptor.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/MarshalAsDescriptor.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Runtime.CompilerServices; -using System; using System.Diagnostics; namespace Internal.TypeSystem diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/MetadataType.Interop.cs b/src/coreclr/tools/Common/TypeSystem/Interop/MetadataType.Interop.cs index eeed1cc9343d9..10e3bbeeb1835 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/MetadataType.Interop.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/MetadataType.Interop.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace Internal.TypeSystem { public enum PInvokeStringFormat diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/MethodDelegator.Interop.cs b/src/coreclr/tools/Common/TypeSystem/Interop/MethodDelegator.Interop.cs index 47291cd62bc63..d9919796639e2 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/MethodDelegator.Interop.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/MethodDelegator.Interop.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem { - partial class MethodDelegator + public partial class MethodDelegator { public override bool IsPInvoke => _wrappedMethod.IsPInvoke; diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/MethodDesc.Interop.cs b/src/coreclr/tools/Common/TypeSystem/Interop/MethodDesc.Interop.cs index c49c654423a7e..39e7e751bbc8a 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/MethodDesc.Interop.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/MethodDesc.Interop.cs @@ -7,7 +7,7 @@ namespace Internal.TypeSystem { // Additional extensions to MethodDesc related to interop - partial class MethodDesc + public partial class MethodDesc { /// /// Gets a value indicating whether this method is a (native unmanaged) platform invoke. @@ -350,7 +350,7 @@ public PInvokeMetadata(string module, string entrypoint, PInvokeFlags flags) } } - partial class InstantiatedMethod + public partial class InstantiatedMethod { public override ParameterMetadata[] GetParameterMetadata() { @@ -358,7 +358,7 @@ public override ParameterMetadata[] GetParameterMetadata() } } - partial class MethodForInstantiatedType + public partial class MethodForInstantiatedType { public override ParameterMetadata[] GetParameterMetadata() { diff --git a/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs b/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs index 8e0a9272392cf..8499fa23d8046 100644 --- a/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs +++ b/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs @@ -9,22 +9,23 @@ using System.Reflection.Metadata; using System.Reflection.Metadata.Ecma335; using System.Reflection.PortableExecutable; -using Internal.TypeSystem; namespace Internal.TypeSystem { - class TypeSystemMetadataEmitter +#pragma warning disable CA1852 + internal class TypeSystemMetadataEmitter +#pragma warning restore CA1852 { - MetadataBuilder _metadataBuilder; - BlobBuilder _ilBuilder; - MethodBodyStreamEncoder _methodBodyStream; - Dictionary _assemblyRefNameHandles = new Dictionary(); - Dictionary _assemblyRefs = new Dictionary(); - Dictionary _typeRefs = new Dictionary(); - Dictionary _methodRefs = new Dictionary(); - Dictionary _fieldRefs = new Dictionary(); - Blob _mvidFixup; - BlobHandle _noArgsVoidReturnStaticMethodSigHandle; + private MetadataBuilder _metadataBuilder; + private BlobBuilder _ilBuilder; + private MethodBodyStreamEncoder _methodBodyStream; + private Dictionary _assemblyRefNameHandles = new Dictionary(); + private Dictionary _assemblyRefs = new Dictionary(); + private Dictionary _typeRefs = new Dictionary(); + private Dictionary _methodRefs = new Dictionary(); + private Dictionary _fieldRefs = new Dictionary(); + private Blob _mvidFixup; + private BlobHandle _noArgsVoidReturnStaticMethodSigHandle; protected TypeSystemContext _typeSystemContext; public TypeSystemMetadataEmitter(AssemblyName assemblyName, TypeSystemContext context, AssemblyFlags flags = default(AssemblyFlags), byte[] publicKeyArray = null, AssemblyHashAlgorithm hashAlgorithm = AssemblyHashAlgorithm.None) @@ -41,7 +42,7 @@ class TypeSystemMetadataEmitter _mvidFixup = mvid.Content; _metadataBuilder.AddModule(0, assemblyNameHandle, mvid.Handle, default(GuidHandle), default(GuidHandle)); - _metadataBuilder.AddAssembly(assemblyNameHandle, assemblyName.Version ?? new Version(0,0,0,0), default(StringHandle), publicKey: publicKeyArray != null ? _metadataBuilder.GetOrAddBlob(publicKeyArray) : default(BlobHandle), flags, AssemblyHashAlgorithm.None); + _metadataBuilder.AddAssembly(assemblyNameHandle, assemblyName.Version ?? new Version(0, 0, 0, 0), default(StringHandle), publicKey: publicKeyArray != null ? _metadataBuilder.GetOrAddBlob(publicKeyArray) : default(BlobHandle), flags, AssemblyHashAlgorithm.None); _metadataBuilder.AddTypeDefinition( default(TypeAttributes), @@ -167,7 +168,7 @@ public EntityHandle EmitMetadataHandleForTypeSystemEntity(TypeSystemEntity entit throw new NotSupportedException(); } } - + public IEnumerable> TypeSystemEntitiesKnown { get @@ -264,7 +265,6 @@ private BlobHandle GetMethodSignatureBlobHandle(MethodSignature sig) private BlobHandle GetFieldSignatureBlobHandle(FieldDesc field) { - var fieldDef = field.GetTypicalFieldDefinition(); var embeddedSigData = field.GetEmbeddedSignatureData(); EmbeddedSignatureDataEmitter signatureDataEmitter; if (embeddedSigData != null && embeddedSigData.Length != 0) @@ -455,9 +455,8 @@ private void EncodeType(BlobBuilder blobBuilder, TypeDesc type, EmbeddedSignatur { blobBuilder.WriteByte((byte)SignatureTypeCode.Void); } - else if (type is SignatureVariable) + else if (type is SignatureVariable sigVar) { - SignatureVariable sigVar = (SignatureVariable)type; SignatureTypeCode code = sigVar.IsMethodSignatureVariable ? SignatureTypeCode.GenericMethodParameter : SignatureTypeCode.GenericTypeParameter; blobBuilder.WriteByte((byte)code); blobBuilder.WriteCompressedInteger(sigVar.Index); @@ -470,9 +469,8 @@ private void EncodeType(BlobBuilder blobBuilder, TypeDesc type, EmbeddedSignatur foreach (var instantiationArg in type.Instantiation) EncodeType(blobBuilder, instantiationArg, signatureDataEmitter); } - else if (type is MetadataType) + else if (type is MetadataType metadataType) { - var metadataType = (MetadataType)type; // Must be class or valuetype blobBuilder.WriteByte(type.IsValueType ? (byte)SignatureTypeKind.ValueType : (byte)SignatureTypeKind.Class); int codedIndex = CodedIndex.TypeDefOrRef(GetTypeRef(metadataType)); @@ -486,12 +484,12 @@ private void EncodeType(BlobBuilder blobBuilder, TypeDesc type, EmbeddedSignatur signatureDataEmitter.Pop(); } - class EmbeddedSignatureDataEmitter + private sealed class EmbeddedSignatureDataEmitter { - EmbeddedSignatureData[] _embeddedData; - int _embeddedDataIndex; - Stack _indexStack = new Stack(); - TypeSystemMetadataEmitter _metadataEmitter; + private EmbeddedSignatureData[] _embeddedData; + private int _embeddedDataIndex; + private Stack _indexStack = new Stack(); + private TypeSystemMetadataEmitter _metadataEmitter; public static EmbeddedSignatureDataEmitter EmptySingleton = new EmbeddedSignatureDataEmitter(null, null); @@ -536,11 +534,11 @@ public void EmitArrayShapeAtCurrentIndexStack(BlobBuilder signatureBuilder, int for (int i = 0; i < boundsStr.Length; i++) { - bounds[i] = Int32.Parse(boundsStr[i]); + bounds[i] = int.Parse(boundsStr[i]); } for (int i = 0; i < loBoundsStr.Length; i++) { - loBounds[i] = Int32.Parse(loBoundsStr[i]); + loBounds[i] = int.Parse(loBoundsStr[i]); } shapeEncoder.Shape(rank, ImmutableArray.Create(bounds), ImmutableArray.Create(loBounds)); @@ -636,7 +634,7 @@ public void Pop() } } - void EncodeMethodSignature(BlobBuilder signatureBuilder, MethodSignature sig, EmbeddedSignatureDataEmitter signatureDataEmitter) + private void EncodeMethodSignature(BlobBuilder signatureBuilder, MethodSignature sig, EmbeddedSignatureDataEmitter signatureDataEmitter) { signatureDataEmitter.Push(); BlobEncoder signatureEncoder = new BlobEncoder(signatureBuilder); @@ -672,7 +670,7 @@ void EncodeMethodSignature(BlobBuilder signatureBuilder, MethodSignature sig, Em signatureDataEmitter.Pop(); } - void EncodeFieldSignature(BlobBuilder signatureBuilder, TypeDesc fieldType, EmbeddedSignatureDataEmitter signatureDataEmitter) + private void EncodeFieldSignature(BlobBuilder signatureBuilder, TypeDesc fieldType, EmbeddedSignatureDataEmitter signatureDataEmitter) { signatureDataEmitter.Push(); BlobEncoder signatureEncoder = new BlobEncoder(signatureBuilder); diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/ArrayType.RuntimeDetermined.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/ArrayType.RuntimeDetermined.cs index 2e05f1b87f2ba..5da5d7f03133d 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/ArrayType.RuntimeDetermined.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/ArrayType.RuntimeDetermined.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem { - partial class ArrayType + public partial class ArrayType { public override TypeDesc GetNonRuntimeDeterminedTypeFromRuntimeDeterminedSubtypeViaSubstitution(Instantiation typeInstantiation, Instantiation methodInstantiation) { @@ -17,7 +17,7 @@ public override TypeDesc GetNonRuntimeDeterminedTypeFromRuntimeDeterminedSubtype } } - partial class ArrayMethod + public partial class ArrayMethod { public override MethodDesc GetNonRuntimeDeterminedMethodFromRuntimeDeterminedMethodViaSubstitution(Instantiation typeInstantiation, Instantiation methodInstantiation) { diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/ByRefType.RuntimeDetermined.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/ByRefType.RuntimeDetermined.cs index 21b4b9a3b067c..8f3426cf753bc 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/ByRefType.RuntimeDetermined.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/ByRefType.RuntimeDetermined.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem { - partial class ByRefType + public partial class ByRefType { public override TypeDesc GetNonRuntimeDeterminedTypeFromRuntimeDeterminedSubtypeViaSubstitution(Instantiation typeInstantiation, Instantiation methodInstantiation) { diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/DefType.RuntimeDetermined.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/DefType.RuntimeDetermined.cs index 81d24031df36d..62799f6ba6145 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/DefType.RuntimeDetermined.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/DefType.RuntimeDetermined.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem { - partial class DefType + public partial class DefType { public override bool IsRuntimeDeterminedSubtype { diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/FieldDesc.RuntimeDetermined.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/FieldDesc.RuntimeDetermined.cs index 748ea1d87720b..f1bf0d968189e 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/FieldDesc.RuntimeDetermined.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/FieldDesc.RuntimeDetermined.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem { - partial class FieldDesc + public partial class FieldDesc { public FieldDesc GetNonRuntimeDeterminedFieldFromRuntimeDeterminedFieldViaSubstitution(Instantiation typeInstantiation, Instantiation methodInstantiation) { diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/FunctionPointerType.RuntimeDetermined.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/FunctionPointerType.RuntimeDetermined.cs index 64767657f56b0..5f2d9b5c8af01 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/FunctionPointerType.RuntimeDetermined.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/FunctionPointerType.RuntimeDetermined.cs @@ -5,7 +5,7 @@ namespace Internal.TypeSystem { - partial class FunctionPointerType + public partial class FunctionPointerType { public override bool IsRuntimeDeterminedSubtype { diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/GenericParameterDesc.RuntimeDetermined.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/GenericParameterDesc.RuntimeDetermined.cs index e2abaf141c484..d6540d7ae4076 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/GenericParameterDesc.RuntimeDetermined.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/GenericParameterDesc.RuntimeDetermined.cs @@ -5,7 +5,7 @@ namespace Internal.TypeSystem { - partial class GenericParameterDesc + public partial class GenericParameterDesc { public sealed override bool IsRuntimeDeterminedSubtype { diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodDesc.RuntimeDetermined.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodDesc.RuntimeDetermined.cs index 909c73465d841..2a66359448f0a 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodDesc.RuntimeDetermined.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodDesc.RuntimeDetermined.cs @@ -1,11 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Debug = System.Diagnostics.Debug; - namespace Internal.TypeSystem { - partial class MethodDesc + public partial class MethodDesc { /// /// Gets the shared runtime determined form of the method. This is a canonical form of the method diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.Diagnostic.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.Diagnostic.cs index aca586c0c1517..40047e9c6ab33 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.Diagnostic.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.Diagnostic.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem { - partial class MethodForRuntimeDeterminedType + public partial class MethodForRuntimeDeterminedType { public override string DiagnosticName => _typicalMethodDef.DiagnosticName; } diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.Sorting.cs index 2aeab414f4aad..2aec790ee0015 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.Sorting.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Functionality related to deterministic ordering of types - partial class MethodForRuntimeDeterminedType + public partial class MethodForRuntimeDeterminedType { protected internal override int ClassCode => 719937490; diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.cs index 24f7ec0eb2d55..d111f8b130af7 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Diagnostics; namespace Internal.TypeSystem diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/ParameterizedType.RuntimeDetermined.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/ParameterizedType.RuntimeDetermined.cs index 430e57596c96b..a241bc7d05018 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/ParameterizedType.RuntimeDetermined.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/ParameterizedType.RuntimeDetermined.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem { - partial class ParameterizedType + public partial class ParameterizedType { public sealed override bool IsRuntimeDeterminedSubtype { diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/PointerType.RuntimeDetermined.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/PointerType.RuntimeDetermined.cs index ef6c1e6bb061e..5219e32e4a581 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/PointerType.RuntimeDetermined.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/PointerType.RuntimeDetermined.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem { - partial class PointerType + public partial class PointerType { public override TypeDesc GetNonRuntimeDeterminedTypeFromRuntimeDeterminedSubtypeViaSubstitution(Instantiation typeInstantiation, Instantiation methodInstantiation) { diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedCanonicalizationAlgorithm.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedCanonicalizationAlgorithm.cs index a0e7c07778374..f3b9094e11efe 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedCanonicalizationAlgorithm.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedCanonicalizationAlgorithm.cs @@ -110,7 +110,7 @@ public static TypeDesc ConvertToCanon(TypeDesc typeToConvert, ref CanonicalFormK else if (typeToConvert.IsRuntimeDeterminedType) { // For non-universal canon cases, RuntimeDeterminedType's passed into this function are either - // reference types (which are turned into normal Canon), or instantiated types (which are handled + // reference types (which are turned into normal Canon), or instantiated types (which are handled // by the above case.). But for UniversalCanon, we can have non-instantiated universal canon // which will reach this case. diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedFieldLayoutAlgorithm.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedFieldLayoutAlgorithm.cs index 7dd50f06f3441..55c3bfbd85f02 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedFieldLayoutAlgorithm.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedFieldLayoutAlgorithm.cs @@ -2,9 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Generic; - -using Debug = System.Diagnostics.Debug; namespace Internal.TypeSystem { @@ -37,7 +34,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp return result; } - public unsafe override ComputedStaticFieldLayout ComputeStaticFieldLayout(DefType defType, StaticLayoutKind layoutKind) + public override unsafe ComputedStaticFieldLayout ComputeStaticFieldLayout(DefType defType, StaticLayoutKind layoutKind) { // Static field layout for a RuntimeDeterminedType is not a supported operation throw new NotSupportedException(); diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.Diagnostic.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.Diagnostic.cs index 91451e43ee613..09899ba8923eb 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.Diagnostic.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.Diagnostic.cs @@ -1,11 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace Internal.TypeSystem { - partial class RuntimeDeterminedType + public partial class RuntimeDeterminedType { public override string DiagnosticName { @@ -19,7 +17,7 @@ public override string DiagnosticNamespace { get { - return String.Concat(_runtimeDeterminedDetailsType.DiagnosticName, "_", _rawCanonType.DiagnosticNamespace); ; + return string.Concat(_runtimeDeterminedDetailsType.DiagnosticName, "_", _rawCanonType.DiagnosticNamespace); ; } } } diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.Sorting.cs index 70d1d7e7348a2..5a1a2293a220e 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.Sorting.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Functionality related to deterministic ordering of types - partial class RuntimeDeterminedType + public partial class RuntimeDeterminedType { protected internal override int ClassCode => 351938209; diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs index df7dbd13dde94..d9f2742c25f84 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using Debug = System.Diagnostics.Debug; @@ -17,11 +16,11 @@ namespace Internal.TypeSystem /// The use of runtime determined types is limited to the dependency analysis and to communicating /// with the codegen backend during shared generic code generation. They should not show up within /// the system otherwise. - /// + /// /// Runtime determined types behave mostly like the canonical type they are wrapping. Most of the overrides /// this type implements will forward the implementation to the 's /// implementation. - /// + /// /// Runtime determined types also behave like signature variables in the sense that they allow being /// substituted during signature instantiation. /// @@ -102,7 +101,7 @@ public override string Namespace { get { - return String.Concat(_runtimeDeterminedDetailsType.Name, "_", _rawCanonType.Namespace); + return string.Concat(_runtimeDeterminedDetailsType.Name, "_", _rawCanonType.Namespace); } } diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/SignatureVariable.RuntimeDetermined.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/SignatureVariable.RuntimeDetermined.cs index 8eff9f5195443..7caa4d7255ca5 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/SignatureVariable.RuntimeDetermined.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/SignatureVariable.RuntimeDetermined.cs @@ -5,7 +5,7 @@ namespace Internal.TypeSystem { - partial class SignatureVariable + public partial class SignatureVariable { public sealed override bool IsRuntimeDeterminedSubtype { diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/TypeDesc.RuntimeDetermined.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/TypeDesc.RuntimeDetermined.cs index dc602f5ed282a..f69f411f1f7dd 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/TypeDesc.RuntimeDetermined.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/TypeDesc.RuntimeDetermined.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem { - partial class TypeDesc + public partial class TypeDesc { /// /// Gets a value indicating whether the concrete type this object represents is unknown diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/TypeSystemContext.RuntimeDetermined.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/TypeSystemContext.RuntimeDetermined.cs index dbbb7442aa4f4..689905e9526d5 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/TypeSystemContext.RuntimeDetermined.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/TypeSystemContext.RuntimeDetermined.cs @@ -8,7 +8,7 @@ namespace Internal.TypeSystem { - partial class TypeSystemContext + public partial class TypeSystemContext { private struct RuntimeDeterminedTypeKey { @@ -21,7 +21,7 @@ public RuntimeDeterminedTypeKey(DefType plainCanonType, GenericParameterDesc det _detailsType = detailsType; } - public class RuntimeDeterminedTypeKeyHashtable : LockFreeReaderHashtable + public sealed class RuntimeDeterminedTypeKeyHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(RuntimeDeterminedTypeKey key) { @@ -96,7 +96,7 @@ public RuntimeDeterminedType RDType } } - public class MethodForRuntimeDeterminedTypeKeyHashtable : LockFreeReaderHashtable + public sealed class MethodForRuntimeDeterminedTypeKeyHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(MethodForRuntimeDeterminedTypeKey key) { diff --git a/src/coreclr/tools/Common/TypeSystem/Serialization/FieldDesc.Serialization.cs b/src/coreclr/tools/Common/TypeSystem/Serialization/FieldDesc.Serialization.cs index 6552d1eaaa80e..c30d2521188db 100644 --- a/src/coreclr/tools/Common/TypeSystem/Serialization/FieldDesc.Serialization.cs +++ b/src/coreclr/tools/Common/TypeSystem/Serialization/FieldDesc.Serialization.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Additional members of FieldDesc related to serialization. - partial class FieldDesc + public partial class FieldDesc { /// /// Gets a value indicating whether this field is not serialized. @@ -19,7 +19,7 @@ public virtual bool IsNotSerialized } } - partial class FieldForInstantiatedType + public partial class FieldForInstantiatedType { public override bool IsNotSerialized { diff --git a/src/coreclr/tools/Common/TypeSystem/Serialization/TypeDesc.Serialization.cs b/src/coreclr/tools/Common/TypeSystem/Serialization/TypeDesc.Serialization.cs index 9c4fcf89376ef..ff129b0885a81 100644 --- a/src/coreclr/tools/Common/TypeSystem/Serialization/TypeDesc.Serialization.cs +++ b/src/coreclr/tools/Common/TypeSystem/Serialization/TypeDesc.Serialization.cs @@ -3,7 +3,7 @@ namespace Internal.TypeSystem { - partial class TypeDesc + public partial class TypeDesc { /// /// Gets a value indicating whether this type is serializable. @@ -17,7 +17,7 @@ public virtual bool IsSerializable } } - partial class InstantiatedType + public partial class InstantiatedType { public override bool IsSerializable { diff --git a/src/coreclr/tools/Common/TypeSystem/Sorting/ArrayType.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Sorting/ArrayType.Sorting.cs index 30993214e5d68..bdd089e939c82 100644 --- a/src/coreclr/tools/Common/TypeSystem/Sorting/ArrayType.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Sorting/ArrayType.Sorting.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Functionality related to deterministic ordering of types - partial class ArrayType + public partial class ArrayType { protected internal override int ClassCode => -1274559616; @@ -19,7 +19,7 @@ protected internal override int CompareToImpl(TypeDesc other, TypeSystemComparer } } - partial class ArrayMethod + public partial class ArrayMethod { protected internal override int ClassCode => 487354154; diff --git a/src/coreclr/tools/Common/TypeSystem/Sorting/ByRefType.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Sorting/ByRefType.Sorting.cs index 031e675c68428..34708718db413 100644 --- a/src/coreclr/tools/Common/TypeSystem/Sorting/ByRefType.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Sorting/ByRefType.Sorting.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Functionality related to deterministic ordering of types - partial class ByRefType + public partial class ByRefType { protected internal override int ClassCode => -959602231; diff --git a/src/coreclr/tools/Common/TypeSystem/Sorting/FieldDesc.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Sorting/FieldDesc.Sorting.cs index a1f7c02a2d592..bf02ec18b86d9 100644 --- a/src/coreclr/tools/Common/TypeSystem/Sorting/FieldDesc.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Sorting/FieldDesc.Sorting.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Functionality related to deterministic ordering of types and members - partial class FieldDesc + public partial class FieldDesc { /// /// Gets an identifier that is the same for all instances of this diff --git a/src/coreclr/tools/Common/TypeSystem/Sorting/FieldForInstantiatedType.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Sorting/FieldForInstantiatedType.Sorting.cs index 1682d6abe97a6..5548241264c2c 100644 --- a/src/coreclr/tools/Common/TypeSystem/Sorting/FieldForInstantiatedType.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Sorting/FieldForInstantiatedType.Sorting.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Functionality related to deterministic ordering of types and members - partial class FieldForInstantiatedType + public partial class FieldForInstantiatedType { protected internal override int ClassCode => 1140200283; diff --git a/src/coreclr/tools/Common/TypeSystem/Sorting/FunctionPointerType.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Sorting/FunctionPointerType.Sorting.cs index e833b9557fa7e..5bcbb190d890f 100644 --- a/src/coreclr/tools/Common/TypeSystem/Sorting/FunctionPointerType.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Sorting/FunctionPointerType.Sorting.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Functionality related to deterministic ordering of types - partial class FunctionPointerType + public partial class FunctionPointerType { protected internal override int ClassCode => -914739489; diff --git a/src/coreclr/tools/Common/TypeSystem/Sorting/InstantiatedMethod.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Sorting/InstantiatedMethod.Sorting.cs index 0fe7eb4686fd2..5527d2813fbd6 100644 --- a/src/coreclr/tools/Common/TypeSystem/Sorting/InstantiatedMethod.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Sorting/InstantiatedMethod.Sorting.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Functionality related to deterministic ordering of types - partial class InstantiatedMethod + public partial class InstantiatedMethod { protected internal override int ClassCode => -873941872; @@ -16,9 +16,9 @@ protected internal override int CompareToImpl(MethodDesc other, TypeSystemCompar // to each other. This is a better heuristic than sorting by method definition // then by instantiation. // - // The goal is to sort methods like SomeClass.SomeMethod, + // The goal is to sort methods like SomeClass.SomeMethod, // near SomeOtherClass.SomeOtherMethod - int result = 0; + int result; // Sort instantiations of the same type together for (int i = 0; i < _instantiation.Length; i++) { diff --git a/src/coreclr/tools/Common/TypeSystem/Sorting/InstantiatedType.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Sorting/InstantiatedType.Sorting.cs index 887effee9706d..ff304295a7afc 100644 --- a/src/coreclr/tools/Common/TypeSystem/Sorting/InstantiatedType.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Sorting/InstantiatedType.Sorting.cs @@ -1,12 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Debug = System.Diagnostics.Debug; - namespace Internal.TypeSystem { // Functionality related to deterministic ordering of types - partial class InstantiatedType + public partial class InstantiatedType { protected internal override int ClassCode => 1150020412; @@ -21,13 +19,13 @@ protected internal override int CompareToImpl(TypeDesc other, TypeSystemComparer // The goal is to sort classes like SomeClass, // near SomeOtherClass - int result = 0; // Sort instantiations of the same type together for (int i = 0; i < _instantiation.Length; i++) { if (i >= otherType._instantiation.Length) return 1; - result = comparer.Compare(_instantiation[i], otherType._instantiation[i]); + + int result = comparer.Compare(_instantiation[i], otherType._instantiation[i]); if (result != 0) return result; } diff --git a/src/coreclr/tools/Common/TypeSystem/Sorting/MethodDesc.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Sorting/MethodDesc.Sorting.cs index baa78bda20360..05f1091628af6 100644 --- a/src/coreclr/tools/Common/TypeSystem/Sorting/MethodDesc.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Sorting/MethodDesc.Sorting.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Functionality related to deterministic ordering of types and members - partial class MethodDesc + public partial class MethodDesc { /// /// Gets an identifier that is the same for all instances of this diff --git a/src/coreclr/tools/Common/TypeSystem/Sorting/MethodForInstantiatedType.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Sorting/MethodForInstantiatedType.Sorting.cs index eabd0ce0a23e7..3de11f8d63484 100644 --- a/src/coreclr/tools/Common/TypeSystem/Sorting/MethodForInstantiatedType.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Sorting/MethodForInstantiatedType.Sorting.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Functionality related to deterministic ordering of types - partial class MethodForInstantiatedType + public partial class MethodForInstantiatedType { protected internal override int ClassCode => 1359759636; diff --git a/src/coreclr/tools/Common/TypeSystem/Sorting/MethodSignature.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Sorting/MethodSignature.Sorting.cs index edeaf981a52eb..4ec7211d7b9a0 100644 --- a/src/coreclr/tools/Common/TypeSystem/Sorting/MethodSignature.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Sorting/MethodSignature.Sorting.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Functionality related to deterministic ordering of types - partial class MethodSignature + public partial class MethodSignature { internal int CompareTo(MethodSignature other, TypeSystemComparer comparer) { diff --git a/src/coreclr/tools/Common/TypeSystem/Sorting/PointerType.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Sorting/PointerType.Sorting.cs index 6d2a13ebe305e..e8eb0276aa5d3 100644 --- a/src/coreclr/tools/Common/TypeSystem/Sorting/PointerType.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Sorting/PointerType.Sorting.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Functionality related to deterministic ordering of types - partial class PointerType + public partial class PointerType { protected internal override int ClassCode => -2124247792; diff --git a/src/coreclr/tools/Common/TypeSystem/Sorting/SignatureVariable.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Sorting/SignatureVariable.Sorting.cs index ddfdbb065da1c..b11a1b3f414f5 100644 --- a/src/coreclr/tools/Common/TypeSystem/Sorting/SignatureVariable.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Sorting/SignatureVariable.Sorting.cs @@ -1,12 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace Internal.TypeSystem { // Functionality related to deterministic ordering of types - partial class SignatureVariable + public partial class SignatureVariable { protected internal sealed override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer) { @@ -14,7 +12,7 @@ protected internal sealed override int CompareToImpl(TypeDesc other, TypeSystemC } } - partial class SignatureTypeVariable + public partial class SignatureTypeVariable { protected internal override int ClassCode { @@ -25,7 +23,7 @@ protected internal override int ClassCode } } - partial class SignatureMethodVariable + public partial class SignatureMethodVariable { protected internal override int ClassCode { diff --git a/src/coreclr/tools/Common/TypeSystem/Sorting/TypeDesc.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Sorting/TypeDesc.Sorting.cs index 7c75359d7cb93..8ed7b8b5374a3 100644 --- a/src/coreclr/tools/Common/TypeSystem/Sorting/TypeDesc.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Sorting/TypeDesc.Sorting.cs @@ -4,7 +4,7 @@ namespace Internal.TypeSystem { // Functionality related to deterministic ordering of types and members - partial class TypeDesc + public partial class TypeDesc { /// /// Gets an identifier that is the same for all instances of this diff --git a/src/coreclr/tools/Common/TypeSystem/Sorting/TypeSystemComparer.cs b/src/coreclr/tools/Common/TypeSystem/Sorting/TypeSystemComparer.cs index 39f795683d6cc..4db2f4e603eb6 100644 --- a/src/coreclr/tools/Common/TypeSystem/Sorting/TypeSystemComparer.cs +++ b/src/coreclr/tools/Common/TypeSystem/Sorting/TypeSystemComparer.cs @@ -131,4 +131,3 @@ public int Compare(MethodSignature x, MethodSignature y) } } } - diff --git a/src/coreclr/tools/aot/.editorconfig b/src/coreclr/tools/aot/.editorconfig index f5e97a5d50a0d..692dc43eab82a 100644 --- a/src/coreclr/tools/aot/.editorconfig +++ b/src/coreclr/tools/aot/.editorconfig @@ -1,3 +1,15 @@ +### Code Style Analyzers + +[*.cs] +# IDE0005: Remove unnecessary usings/imports +dotnet_diagnostic.IDE0005.severity = error + +# IL3000: Avoid accessing Assembly file path when publishing as a single file +dotnet_diagnostic.IL3000.severity = suggestion + +# CS0176: Cannot be accessed with an instance ref +dotnet_diagnostic.CS0176.severity = silent + # Linker port settings: # A newline ending every file # Use tabs as indentation @@ -28,6 +40,9 @@ csharp_style_expression_bodied_properties = true:none csharp_style_expression_bodied_indexers = true:none csharp_style_expression_bodied_accessors = true:none +# IDE0073: The file header does not match the required text +dotnet_diagnostic.IDE0073.severity = none + [Mono.Linker.Tests/**.cs] indent_style = tab indent_size = 4 diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/AnalysisBasedMetadataManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/AnalysisBasedMetadataManager.cs index 1eec083ff5943..f287624d266b4 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/AnalysisBasedMetadataManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/AnalysisBasedMetadataManager.cs @@ -56,7 +56,7 @@ public AnalysisBasedMetadataManager( { _modulesWithMetadata = new List(modulesWithMetadata); _typesWithRootedCctorContext = new List(rootedCctorContexts); - + foreach (var refType in reflectableTypes) { _reflectableTypes.Add(refType.Entity, refType.Category); @@ -214,7 +214,7 @@ private struct Policy : IMetadataPolicy private readonly MetadataBlockingPolicy _blockingPolicy; private readonly AnalysisBasedMetadataManager _parent; - public Policy(MetadataBlockingPolicy blockingPolicy, + public Policy(MetadataBlockingPolicy blockingPolicy, AnalysisBasedMetadataManager parent) { _blockingPolicy = blockingPolicy; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BlockedInternalsBlockingPolicy.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BlockedInternalsBlockingPolicy.cs index 8d07a9363e249..7abb3b45155cb 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BlockedInternalsBlockingPolicy.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BlockedInternalsBlockingPolicy.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.TypeSystem; using Internal.TypeSystem.Ecma; @@ -25,7 +23,7 @@ private enum ModuleBlockingMode FullyBlocked, } - private class ModuleBlockingState + private sealed class ModuleBlockingState { public ModuleDesc Module { get; } public ModuleBlockingMode BlockingMode { get; } @@ -36,12 +34,12 @@ public ModuleBlockingState(ModuleDesc module, ModuleBlockingMode mode) } } - private class BlockedModulesHashtable : LockFreeReaderHashtable + private sealed class BlockedModulesHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(ModuleDesc key) => key.GetHashCode(); protected override int GetValueHashCode(ModuleBlockingState value) => value.Module.GetHashCode(); - protected override bool CompareKeyToValue(ModuleDesc key, ModuleBlockingState value) => Object.ReferenceEquals(key, value.Module); - protected override bool CompareValueToValue(ModuleBlockingState value1, ModuleBlockingState value2) => Object.ReferenceEquals(value1.Module, value2.Module); + protected override bool CompareKeyToValue(ModuleDesc key, ModuleBlockingState value) => ReferenceEquals(key, value.Module); + protected override bool CompareValueToValue(ModuleBlockingState value1, ModuleBlockingState value2) => ReferenceEquals(value1.Module, value2.Module); protected override ModuleBlockingState CreateValueFromKey(ModuleDesc module) { ModuleBlockingMode blockingMode = ModuleBlockingMode.None; @@ -60,7 +58,7 @@ protected override ModuleBlockingState CreateValueFromKey(ModuleDesc module) } private BlockedModulesHashtable _blockedModules = new BlockedModulesHashtable(); - private class BlockingState + private sealed class BlockingState { public EcmaType Type { get; } public bool IsBlocked { get; } @@ -71,7 +69,7 @@ public BlockingState(EcmaType type, bool isBlocked) } } - private class BlockedTypeHashtable : LockFreeReaderHashtable + private sealed class BlockedTypeHashtable : LockFreeReaderHashtable { private readonly BlockedModulesHashtable _blockedModules; @@ -82,8 +80,8 @@ public BlockedTypeHashtable(BlockedModulesHashtable blockedModules) protected override int GetKeyHashCode(EcmaType key) => key.GetHashCode(); protected override int GetValueHashCode(BlockingState value) => value.Type.GetHashCode(); - protected override bool CompareKeyToValue(EcmaType key, BlockingState value) => Object.ReferenceEquals(key, value.Type); - protected override bool CompareValueToValue(BlockingState value1, BlockingState value2) => Object.ReferenceEquals(value1.Type, value2.Type); + protected override bool CompareKeyToValue(EcmaType key, BlockingState value) => ReferenceEquals(key, value.Type); + protected override bool CompareValueToValue(BlockingState value1, BlockingState value2) => ReferenceEquals(value1.Type, value2.Type); protected override BlockingState CreateValueFromKey(EcmaType type) { ModuleBlockingMode moduleBlockingMode = _blockedModules.GetOrCreateValue(type.EcmaModule).BlockingMode; @@ -120,7 +118,7 @@ private bool ComputeIsBlocked(EcmaType type, ModuleBlockingMode blockingMode) DefType containingType = type.ContainingType; var typeDefinition = type.MetadataReader.GetTypeDefinition(type.Handle); - + if (containingType == null) { if ((typeDefinition.Attributes & TypeAttributes.Public) == 0) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitution.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitution.cs index be138cefa7de1..769f088c81da4 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitution.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitution.cs @@ -12,10 +12,10 @@ internal sealed class BodySubstitution { private object _value; - private readonly static object Throw = new object(); + private static readonly object Throw = new object(); - public readonly static BodySubstitution ThrowingBody = new BodySubstitution(Throw); - public readonly static BodySubstitution EmptyBody = new BodySubstitution(null); + public static readonly BodySubstitution ThrowingBody = new BodySubstitution(Throw); + public static readonly BodySubstitution EmptyBody = new BodySubstitution(null); public object Value { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitutionParser.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitutionParser.cs index 3aade53731c65..a0025c2d3e790 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitutionParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitutionParser.cs @@ -114,7 +114,7 @@ protected override void ProcessField(TypeDesc type, XPathNavigator fieldNav) return; } - if (String.Equals(GetAttribute(fieldNav, "initialize"), "true", StringComparison.InvariantCultureIgnoreCase)) + if (string.Equals(GetAttribute(fieldNav, "initialize"), "true", StringComparison.InvariantCultureIgnoreCase)) { // We would need to also mess with the cctor of the type to set the field to this value: // @@ -128,7 +128,7 @@ protected override void ProcessField(TypeDesc type, XPathNavigator fieldNav) _fieldSubstitutions[field] = substitution; } - static MethodDesc FindMethod(TypeDesc type, string signature) + private static MethodDesc FindMethod(TypeDesc type, string signature) { foreach (MethodDesc meth in type.GetMethods()) if (signature == GetMethodSignature(meth, includeGenericParameters: true)) @@ -136,7 +136,7 @@ static MethodDesc FindMethod(TypeDesc type, string signature) return null; } - private object TryCreateSubstitution(TypeDesc type, string value) + private static object TryCreateSubstitution(TypeDesc type, string value) { switch (type.UnderlyingType.Category) { @@ -148,7 +148,7 @@ private object TryCreateSubstitution(TypeDesc type, string value) break; case TypeFlags.Boolean: - if (String.IsNullOrEmpty(value)) + if (string.IsNullOrEmpty(value)) return 0; else if (bool.TryParse(value, out bool bvalue)) return bvalue ? 1 : 0; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs index 018226ef84270..02057abde7e4c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.IO; -using System.Runtime.InteropServices; using ILCompiler.DependencyAnalysis; using ILCompiler.DependencyAnalysisFramework; @@ -266,7 +265,7 @@ public bool NeedsRuntimeLookup(ReadyToRunHelperId lookupKind, object targetOfLoo public ReadyToRunHelperId GetLdTokenHelperForType(TypeDesc type) { bool canConstructPerWholeProgramAnalysis = _devirtualizationManager == null ? true : _devirtualizationManager.CanConstructType(type); - bool creationAllowed = DependencyAnalysis.ConstructedEETypeNode.CreationAllowed(type); + bool creationAllowed = ConstructedEETypeNode.CreationAllowed(type); return (canConstructPerWholeProgramAnalysis && creationAllowed) ? ReadyToRunHelperId.TypeHandle : ReadyToRunHelperId.NecessaryTypeHandle; @@ -520,17 +519,11 @@ public MethodDesc GetTargetOfGenericVirtualMethodCall(MethodDesc calledMethod) CompilationResults ICompilation.Compile(string outputFile, ObjectDumper dumper) { - if (dumper != null) - { - dumper.Begin(); - } + dumper?.Begin(); CompileInternal(outputFile, dumper); - if (dumper != null) - { - dumper.End(); - } + dumper?.End(); return new CompilationResults(_dependencyGraph, _nodeFactory); } @@ -554,18 +547,18 @@ protected override int GetValueHashCode(MethodILData value) } protected override bool CompareKeyToValue(MethodDesc key, MethodILData value) { - return Object.ReferenceEquals(key, value.Method); + return ReferenceEquals(key, value.Method); } protected override bool CompareValueToValue(MethodILData value1, MethodILData value2) { - return Object.ReferenceEquals(value1.Method, value2.Method); + return ReferenceEquals(value1.Method, value2.Method); } protected override MethodILData CreateValueFromKey(MethodDesc key) { return new MethodILData() { Method = key, MethodIL = ILProvider.GetMethodIL(key) }; } - internal class MethodILData + internal sealed class MethodILData { public MethodDesc Method; public MethodIL MethodIL; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilationBuilder.Aot.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilationBuilder.Aot.cs index 232df5cd22d4e..bf1a053c0c612 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilationBuilder.Aot.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilationBuilder.Aot.cs @@ -3,11 +3,9 @@ using System; -using Internal.JitInterface; - namespace ILCompiler { - partial class CompilationBuilder + public partial class CompilationBuilder { private PreinitializationManager _preinitializationManager; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilationModuleGroup.Aot.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilationModuleGroup.Aot.cs index a7522ba8810a9..a56072d34842e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilationModuleGroup.Aot.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilationModuleGroup.Aot.cs @@ -5,7 +5,7 @@ namespace ILCompiler { - partial class CompilationModuleGroup : IInliningPolicy + public partial class CompilationModuleGroup : IInliningPolicy { /// /// If true, type dictionary of "type" is in the module to be compiled @@ -25,13 +25,13 @@ partial class CompilationModuleGroup : IInliningPolicy /// public abstract bool IsSingleFileCompilation { get; } /// - /// If true, the full type should be generated. This occurs in situations where the type is + /// If true, the full type should be generated. This occurs in situations where the type is /// shared between modules (generics, parameterized types), or the type lives in a different module /// and therefore needs a full VTable /// public abstract bool ShouldProduceFullVTable(TypeDesc type); /// - /// If true, the necessary type should be promoted to a full type should be generated. + /// If true, the necessary type should be promoted to a full type should be generated. /// public abstract bool ShouldPromoteToFullType(TypeDesc type); /// diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerGeneratedInteropStubManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerGeneratedInteropStubManager.cs index 5c83e2211c9c5..b56ca367618e9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerGeneratedInteropStubManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerGeneratedInteropStubManager.cs @@ -28,7 +28,7 @@ public sealed override PInvokeILProvider CreatePInvokeILProvider() { return new PInvokeILProvider(_pInvokeILEmitterConfiguration, _interopStateManager); } - + public sealed override void AddToReadyToRunHeader(ReadyToRunHeaderNode header, NodeFactory nodeFactory, ExternalReferencesTableNode commonFixupsTableNode) { var delegateMapNode = new DelegateMarshallingStubMapNode(commonFixupsTableNode, _interopStateManager); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerMetadataFieldLayoutAlgorithm.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerMetadataFieldLayoutAlgorithm.cs index 8c0882b08f231..1bb77e03eeb97 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerMetadataFieldLayoutAlgorithm.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerMetadataFieldLayoutAlgorithm.cs @@ -1,16 +1,13 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; - using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; namespace ILCompiler { - internal class CompilerMetadataFieldLayoutAlgorithm : MetadataFieldLayoutAlgorithm + internal sealed class CompilerMetadataFieldLayoutAlgorithm : MetadataFieldLayoutAlgorithm { // GC statics start with a pointer to the "MethodTable" that signals the size and GCDesc to the GC public static LayoutInt GetGCStaticFieldOffset(TypeSystemContext context) => context.Target.LayoutPointerSize; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Aot.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Aot.cs index 0d07c51c40d3e..97176e404cb82 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Aot.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Aot.cs @@ -12,7 +12,7 @@ namespace ILCompiler { - partial class CompilerTypeSystemContext + public partial class CompilerTypeSystemContext { // Chosen rather arbitrarily. For the app that I was looking at, cutoff point of 7 compiled // more than 10 minutes on a release build of the compiler, and I lost patience. @@ -57,10 +57,7 @@ public CompilerTypeSystemContext(TargetDetails details, SharedGenericsMode gener protected override RuntimeInterfacesAlgorithm GetRuntimeInterfacesAlgorithmForNonPointerArrayType(ArrayType type) { - if (_arrayOfTRuntimeInterfacesAlgorithm == null) - { - _arrayOfTRuntimeInterfacesAlgorithm = new ArrayOfTRuntimeInterfacesAlgorithm(SystemModule.GetKnownType("System", "Array`1")); - } + _arrayOfTRuntimeInterfacesAlgorithm ??= new ArrayOfTRuntimeInterfacesAlgorithm(SystemModule.GetKnownType("System", "Array`1")); return _arrayOfTRuntimeInterfacesAlgorithm; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs index beba5d59dc852..c38e5cfceb89f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Text; using Internal.TypeSystem; using Internal.IL; @@ -51,7 +50,7 @@ namespace ILCompiler { // Contains functionality related to pseudotypes representing boxed instances of value types - partial class CompilerTypeSystemContext + public partial class CompilerTypeSystemContext { /// /// For a shared (canonical) instance method on a generic valuetype, gets a method that can be used to call the @@ -152,7 +151,7 @@ public BoxedValuetypeHashtableKey(MetadataType valueType, ModuleDesc owningModul } } - private class BoxedValuetypeHashtable : LockFreeReaderHashtable + private sealed class BoxedValuetypeHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(BoxedValuetypeHashtableKey key) { @@ -164,13 +163,13 @@ protected override int GetValueHashCode(BoxedValueType value) } protected override bool CompareKeyToValue(BoxedValuetypeHashtableKey key, BoxedValueType value) { - return Object.ReferenceEquals(key.ValueType, value.ValueTypeRepresented) && - Object.ReferenceEquals(key.OwningModule, value.Module); + return ReferenceEquals(key.ValueType, value.ValueTypeRepresented) && + ReferenceEquals(key.OwningModule, value.Module); } protected override bool CompareValueToValue(BoxedValueType value1, BoxedValueType value2) { - return Object.ReferenceEquals(value1.ValueTypeRepresented, value2.ValueTypeRepresented) && - Object.ReferenceEquals(value1.Module, value2.Module); + return ReferenceEquals(value1.ValueTypeRepresented, value2.ValueTypeRepresented) && + ReferenceEquals(value1.Module, value2.Module); } protected override BoxedValueType CreateValueFromKey(BoxedValuetypeHashtableKey key) { @@ -191,7 +190,7 @@ public UnboxingThunkHashtableKey(MethodDesc targetMethod, BoxedValueType owningT } } - private class UnboxingThunkHashtable : LockFreeReaderHashtable + private sealed class UnboxingThunkHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(UnboxingThunkHashtableKey key) { @@ -203,13 +202,13 @@ protected override int GetValueHashCode(GenericUnboxingThunk value) } protected override bool CompareKeyToValue(UnboxingThunkHashtableKey key, GenericUnboxingThunk value) { - return Object.ReferenceEquals(key.TargetMethod, value.TargetMethod) && - Object.ReferenceEquals(key.OwningType, value.OwningType); + return ReferenceEquals(key.TargetMethod, value.TargetMethod) && + ReferenceEquals(key.OwningType, value.OwningType); } protected override bool CompareValueToValue(GenericUnboxingThunk value1, GenericUnboxingThunk value2) { - return Object.ReferenceEquals(value1.TargetMethod, value2.TargetMethod) && - Object.ReferenceEquals(value1.OwningType, value2.OwningType); + return ReferenceEquals(value1.TargetMethod, value2.TargetMethod) && + ReferenceEquals(value1.OwningType, value2.OwningType); } protected override GenericUnboxingThunk CreateValueFromKey(UnboxingThunkHashtableKey key) { @@ -218,7 +217,7 @@ protected override GenericUnboxingThunk CreateValueFromKey(UnboxingThunkHashtabl } private UnboxingThunkHashtable _unboxingThunkHashtable = new UnboxingThunkHashtable(); - private class NonGenericUnboxingThunkHashtable : LockFreeReaderHashtable + private sealed class NonGenericUnboxingThunkHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(UnboxingThunkHashtableKey key) { @@ -230,13 +229,13 @@ protected override int GetValueHashCode(UnboxingThunk value) } protected override bool CompareKeyToValue(UnboxingThunkHashtableKey key, UnboxingThunk value) { - return Object.ReferenceEquals(key.TargetMethod, value.TargetMethod) && - Object.ReferenceEquals(key.OwningType, value.OwningType); + return ReferenceEquals(key.TargetMethod, value.TargetMethod) && + ReferenceEquals(key.OwningType, value.OwningType); } protected override bool CompareValueToValue(UnboxingThunk value1, UnboxingThunk value2) { - return Object.ReferenceEquals(value1.TargetMethod, value2.TargetMethod) && - Object.ReferenceEquals(value1.OwningType, value2.OwningType); + return ReferenceEquals(value1.TargetMethod, value2.TargetMethod) && + ReferenceEquals(value1.OwningType, value2.OwningType); } protected override UnboxingThunk CreateValueFromKey(UnboxingThunkHashtableKey key) { @@ -250,7 +249,7 @@ protected override UnboxingThunk CreateValueFromKey(UnboxingThunkHashtableKey ke /// A type with an identical layout to the layout of a boxed value type. /// The type has a single field of the type of the valuetype it represents. /// - private partial class BoxedValueType : MetadataType, INonEmittableType + private sealed partial class BoxedValueType : MetadataType, INonEmittableType { public MetadataType ValueTypeRepresented { get; } @@ -380,7 +379,7 @@ public MethodDesc GetTargetOfSpecialUnboxingThunk(MethodDesc method) /// /// Represents a thunk to call shared instance method on boxed valuetypes. /// - private partial class GenericUnboxingThunk : ILStubMethod + private sealed partial class GenericUnboxingThunk : ILStubMethod { private MethodDesc _targetMethod; private ValueTypeInstanceMethodWithHiddenParameter _nakedTargetMethod; @@ -466,7 +465,7 @@ public override MethodIL EmitIL() /// /// Represents a thunk to call instance method on boxed valuetypes. /// - private partial class UnboxingThunk : ILStubMethod + private sealed partial class UnboxingThunk : ILStubMethod { private MethodDesc _targetMethod; private BoxedValueType _owningType; @@ -565,7 +564,7 @@ public override MethodIL EmitIL() /// signature. This is so that we can refer to the parameter from IL. References to this method will /// be replaced by the actual instance method after codegen is done. /// - internal partial class ValueTypeInstanceMethodWithHiddenParameter : MethodDesc + internal sealed partial class ValueTypeInstanceMethodWithHiddenParameter : MethodDesc { private MethodDesc _methodRepresented; private MethodSignature _signature; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.DelegateInfo.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.DelegateInfo.cs index a021e39691d22..abd33f4726ac2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.DelegateInfo.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.DelegateInfo.cs @@ -1,16 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.IL; using Internal.TypeSystem; namespace ILCompiler { - partial class CompilerTypeSystemContext + public partial class CompilerTypeSystemContext { - private class DelegateInfoHashtable : LockFreeReaderHashtable + private sealed class DelegateInfoHashtable : LockFreeReaderHashtable { private readonly DelegateFeature _delegateFeatures; @@ -27,11 +25,11 @@ protected override int GetValueHashCode(DelegateInfo value) } protected override bool CompareKeyToValue(TypeDesc key, DelegateInfo value) { - return Object.ReferenceEquals(key, value.Type); + return ReferenceEquals(key, value.Type); } protected override bool CompareValueToValue(DelegateInfo value1, DelegateInfo value2) { - return Object.ReferenceEquals(value1.Type, value2.Type); + return ReferenceEquals(value1.Type, value2.Type); } protected override DelegateInfo CreateValueFromKey(TypeDesc key) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.DynamicInvoke.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.DynamicInvoke.cs index f67306c264149..38dc8e080c882 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.DynamicInvoke.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.DynamicInvoke.cs @@ -4,13 +4,11 @@ using Internal.IL.Stubs; using Internal.TypeSystem; -using Debug = System.Diagnostics.Debug; - namespace ILCompiler { - partial class CompilerTypeSystemContext + public partial class CompilerTypeSystemContext { - private class DynamicInvokeThunkHashtable : LockFreeReaderHashtable + private sealed class DynamicInvokeThunkHashtable : LockFreeReaderHashtable { protected override bool CompareKeyToValue(MethodSignature key, DynamicInvokeMethodThunk value) => key.Equals(value.TargetSignature); protected override bool CompareValueToValue(DynamicInvokeMethodThunk value1, DynamicInvokeMethodThunk value2) => value1.TargetSignature.Equals(value2.TargetSignature) && value1.OwningType == value2.OwningType; @@ -21,7 +19,8 @@ protected override DynamicInvokeMethodThunk CreateValueFromKey(MethodSignature k return new DynamicInvokeMethodThunk(((CompilerTypeSystemContext)key.Context).GeneratedAssembly.GetGlobalModuleType(), key); } } - DynamicInvokeThunkHashtable _dynamicInvokeThunks = new DynamicInvokeThunkHashtable(); + + private DynamicInvokeThunkHashtable _dynamicInvokeThunks = new DynamicInvokeThunkHashtable(); public MethodDesc GetDynamicInvokeThunk(MethodSignature signature, bool valueTypeInstanceMethod) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs index b777e28a2d144..283153caae470 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs @@ -10,9 +10,9 @@ namespace ILCompiler { - partial class CompilerTypeSystemContext + public partial class CompilerTypeSystemContext { - private class EnumInfo + private sealed class EnumInfo { public TypeDesc Type => EqualsMethod.OwningType; @@ -28,7 +28,7 @@ public EnumInfo(TypeDesc enumType) } } - private class EnumInfoHashtable : LockFreeReaderHashtable + private sealed class EnumInfoHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(TypeDesc key) => key.GetHashCode(); protected override int GetValueHashCode(EnumInfo value) => value.Type.GetHashCode(); @@ -78,8 +78,7 @@ protected virtual IEnumerable GetAllMethodsForEnum(TypeDesc enumType yield break; } - if (_objectEqualsMethod == null) - _objectEqualsMethod = GetWellKnownType(WellKnownType.Object).GetMethod("Equals", null); + _objectEqualsMethod ??= GetWellKnownType(WellKnownType.Object).GetMethod("Equals", null); // If the classlib doesn't have Object.Equals, we don't need this. if (_objectEqualsMethod == null) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.Sorting.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.Sorting.cs index 1fc7bd2414e33..135c50cc5b00c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.Sorting.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.Sorting.cs @@ -7,10 +7,10 @@ namespace ILCompiler { - partial class CompilerTypeSystemContext + public partial class CompilerTypeSystemContext { // Functionality related to deterministic ordering of types and members - partial class CompilerGeneratedType : MetadataType + internal partial class CompilerGeneratedType : MetadataType { protected override int ClassCode => -1036681447; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs index 280f2d85684a3..d18c44ec8706c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs @@ -13,7 +13,7 @@ namespace ILCompiler { - partial class CompilerTypeSystemContext + public partial class CompilerTypeSystemContext { private ModuleDesc _generatedAssembly; @@ -30,7 +30,7 @@ public ModuleDesc GeneratedAssembly } } - private class CompilerGeneratedAssembly : ModuleDesc, IAssemblyDesc + private sealed class CompilerGeneratedAssembly : ModuleDesc, IAssemblyDesc { private MetadataType _globalModuleType; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs index f91414132f609..53c34efc0ef70 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Generic; -using System.Text; using Internal.TypeSystem; using Internal.IL; @@ -62,7 +60,7 @@ namespace ILCompiler { // Contains functionality related to instantiating thunks for default interface methods - partial class CompilerTypeSystemContext + public partial class CompilerTypeSystemContext { private const int UseContextFromRuntime = -1; @@ -127,7 +125,7 @@ public DefaultInterfaceMethodImplementationInstantiationThunkHashtableKey(Method } } - private class DefaultInterfaceMethodImplementationInstantiationThunkHashtable : LockFreeReaderHashtable + private sealed class DefaultInterfaceMethodImplementationInstantiationThunkHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(DefaultInterfaceMethodImplementationInstantiationThunkHashtableKey key) { @@ -139,12 +137,12 @@ protected override int GetValueHashCode(DefaultInterfaceMethodImplementationInst } protected override bool CompareKeyToValue(DefaultInterfaceMethodImplementationInstantiationThunkHashtableKey key, DefaultInterfaceMethodImplementationInstantiationThunk value) { - return Object.ReferenceEquals(key.TargetMethod, value.TargetMethod) && + return ReferenceEquals(key.TargetMethod, value.TargetMethod) && key.InterfaceIndex == value.InterfaceIndex; } protected override bool CompareValueToValue(DefaultInterfaceMethodImplementationInstantiationThunk value1, DefaultInterfaceMethodImplementationInstantiationThunk value2) { - return Object.ReferenceEquals(value1.TargetMethod, value2.TargetMethod) && + return ReferenceEquals(value1.TargetMethod, value2.TargetMethod) && value1.InterfaceIndex == value2.InterfaceIndex; } protected override DefaultInterfaceMethodImplementationInstantiationThunk CreateValueFromKey(DefaultInterfaceMethodImplementationInstantiationThunkHashtableKey key) @@ -158,7 +156,7 @@ protected override DefaultInterfaceMethodImplementationInstantiationThunk Create /// /// Represents a thunk to call shared instance method on generic interfaces. /// - private partial class DefaultInterfaceMethodImplementationInstantiationThunk : ILStubMethod, IPrefixMangledMethod + private sealed partial class DefaultInterfaceMethodImplementationInstantiationThunk : ILStubMethod, IPrefixMangledMethod { private readonly MethodDesc _targetMethod; private readonly DefaultInterfaceMethodImplementationWithHiddenParameter _nakedTargetMethod; @@ -254,7 +252,7 @@ public override MethodIL EmitIL() /// signature. This is so that we can refer to the parameter from IL. References to this method will /// be replaced by the actual instance method after codegen is done. /// - internal partial class DefaultInterfaceMethodImplementationWithHiddenParameter : MethodDesc + internal sealed partial class DefaultInterfaceMethodImplementationWithHiddenParameter : MethodDesc { private readonly MethodDesc _methodRepresented; private readonly TypeDesc _owningType; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Mangling.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Mangling.cs index edbb37fedb4c2..676f3ae77a970 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Mangling.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Mangling.cs @@ -1,15 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using Internal.TypeSystem; namespace ILCompiler { // Contains functionality related to name mangling - partial class CompilerTypeSystemContext + public partial class CompilerTypeSystemContext { - partial class BoxedValueType : IPrefixMangledType + private partial class BoxedValueType : IPrefixMangledType { TypeDesc IPrefixMangledType.BaseType { @@ -28,7 +27,7 @@ string IPrefixMangledType.Prefix } } - partial class GenericUnboxingThunk : IPrefixMangledMethod + private partial class GenericUnboxingThunk : IPrefixMangledMethod { MethodDesc IPrefixMangledMethod.BaseMethod { @@ -47,7 +46,7 @@ string IPrefixMangledMethod.Prefix } } - partial class UnboxingThunk : IPrefixMangledMethod + private partial class UnboxingThunk : IPrefixMangledMethod { MethodDesc IPrefixMangledMethod.BaseMethod { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Sorting.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Sorting.cs index 62666ae4da581..92f553ce526f9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Sorting.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Sorting.cs @@ -6,9 +6,9 @@ namespace ILCompiler { // Functionality related to deterministic ordering of types and members - partial class CompilerTypeSystemContext + public partial class CompilerTypeSystemContext { - partial class BoxedValueType + private partial class BoxedValueType { protected override int ClassCode => 1062019524; @@ -18,7 +18,7 @@ protected override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer } } - partial class GenericUnboxingThunk + private partial class GenericUnboxingThunk { protected override int ClassCode => -247515475; @@ -29,7 +29,7 @@ protected override int CompareToImpl(MethodDesc other, TypeSystemComparer compar } } - partial class UnboxingThunk + private partial class UnboxingThunk { protected override int ClassCode => 446545583; @@ -40,7 +40,7 @@ protected override int CompareToImpl(MethodDesc other, TypeSystemComparer compar } } - partial class ValueTypeInstanceMethodWithHiddenParameter + internal partial class ValueTypeInstanceMethodWithHiddenParameter { protected override int ClassCode => 2131875345; @@ -51,7 +51,7 @@ protected override int CompareToImpl(MethodDesc other, TypeSystemComparer compar } } - partial class DefaultInterfaceMethodImplementationInstantiationThunk + private partial class DefaultInterfaceMethodImplementationInstantiationThunk { protected override int ClassCode => -789598; @@ -67,7 +67,7 @@ protected override int CompareToImpl(MethodDesc other, TypeSystemComparer compar } } - partial class DefaultInterfaceMethodImplementationWithHiddenParameter + internal partial class DefaultInterfaceMethodImplementationWithHiddenParameter { protected override int ClassCode => 4903209; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs index 738b43554182c..e4ffab14cd713 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs @@ -10,11 +10,11 @@ namespace ILCompiler { - partial class CompilerTypeSystemContext + public partial class CompilerTypeSystemContext { private MethodDesc _objectEqualsMethod; - private class ValueTypeMethodHashtable : LockFreeReaderHashtable + private sealed class ValueTypeMethodHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(DefType key) => key.GetHashCode(); protected override int GetValueHashCode(MethodDesc value) => value.OwningType.GetHashCode(); @@ -54,8 +54,7 @@ protected virtual IEnumerable GetAllMethodsForValueType(TypeDesc val private bool RequiresGetFieldHelperMethod(MetadataType valueType) { - if (_objectEqualsMethod == null) - _objectEqualsMethod = GetWellKnownType(WellKnownType.Object).GetMethod("Equals", null); + _objectEqualsMethod ??= GetWellKnownType(WellKnownType.Object).GetMethod("Equals", null); // If the classlib doesn't have Object.Equals, we don't need this. if (_objectEqualsMethod == null) @@ -77,7 +76,7 @@ private bool RequiresGetFieldHelperMethod(MetadataType valueType) return !_typeStateHashtable.GetOrCreateValue(valueType).CanCompareValueTypeBits; } - private class TypeState + private sealed class TypeState { private enum Flags { @@ -180,7 +179,7 @@ private bool ComputeCanCompareValueTypeBits(MetadataType type) } } - private class TypeStateHashtable : LockFreeReaderHashtable + private sealed class TypeStateHashtable : LockFreeReaderHashtable { protected override int GetKeyHashCode(TypeDesc key) => key.GetHashCode(); protected override int GetValueHashCode(TypeState value) => value.Type.GetHashCode(); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ArrayValue.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ArrayValue.cs index 23740b13ef31a..c6b8010e5077e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ArrayValue.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ArrayValue.cs @@ -14,7 +14,7 @@ namespace ILLink.Shared.TrimAnalysis { - partial record ArrayValue + internal partial record ArrayValue { public static MultiValue Create(MultiValue size, TypeDesc elementType) { @@ -35,7 +35,7 @@ public static ArrayValue Create(int size, TypeDesc elementType) /// /// Constructs an array value of the given size /// - ArrayValue(SingleValue size, TypeDesc elementType) + private ArrayValue(SingleValue size, TypeDesc elementType) { Size = size; ElementType = elementType; @@ -102,11 +102,11 @@ public override string ToString() { if (!first) { - result.Append(","); + result.Append(','); first = false; } - result.Append("("); + result.Append('('); result.Append(element.Key); result.Append(",("); bool firstValue = true; @@ -114,7 +114,7 @@ public override string ToString() { if (firstValue) { - result.Append(","); + result.Append(','); firstValue = false; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/AttributeDataFlow.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/AttributeDataFlow.cs index afdc85ab9e06e..c524038d74d97 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/AttributeDataFlow.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/AttributeDataFlow.cs @@ -24,10 +24,10 @@ namespace ILCompiler.Dataflow { public readonly struct AttributeDataFlow { - readonly Logger _logger; - readonly NodeFactory _factory; - readonly FlowAnnotations _annotations; - readonly MessageOrigin _origin; + private readonly Logger _logger; + private readonly NodeFactory _factory; + private readonly FlowAnnotations _annotations; + private readonly MessageOrigin _origin; public AttributeDataFlow(Logger logger, NodeFactory factory, FlowAnnotations annotations, in MessageOrigin origin) { @@ -80,7 +80,7 @@ public AttributeDataFlow(Logger logger, NodeFactory factory, FlowAnnotations ann return result; } - void ProcessAttributeDataflow(MethodDesc method, ImmutableArray arguments, ref DependencyList? result) + private void ProcessAttributeDataflow(MethodDesc method, ImmutableArray arguments, ref DependencyList? result) { for (int i = 0; i < method.Signature.Length; i++) { @@ -106,7 +106,7 @@ public void ProcessAttributeDataflow(FieldDesc field, object? value, ref Depende } } - MultiValue GetValueForCustomAttributeArgument(object? argument) + private static MultiValue GetValueForCustomAttributeArgument(object? argument) => argument switch { TypeDesc td => new SystemTypeValue(td), @@ -116,7 +116,7 @@ MultiValue GetValueForCustomAttributeArgument(object? argument) _ => throw new InvalidOperationException() }; - void RequireDynamicallyAccessedMembers( + private void RequireDynamicallyAccessedMembers( in DiagnosticContext diagnosticContext, in MultiValue value, ValueWithDynamicallyAccessedMembers targetValue, diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedCallGraph.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedCallGraph.cs index 643e0a6a4bf13..f37894a5875a5 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedCallGraph.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedCallGraph.cs @@ -5,19 +5,18 @@ using System.Diagnostics; using Internal.TypeSystem; -using Internal.TypeSystem.Ecma; #nullable enable namespace ILCompiler.Dataflow { - sealed class CompilerGeneratedCallGraph + internal sealed class CompilerGeneratedCallGraph { - readonly Dictionary> _callGraph; + private readonly Dictionary> _callGraph; public CompilerGeneratedCallGraph() => _callGraph = new Dictionary>(); - void TrackCallInternal(TypeSystemEntity fromMember, TypeSystemEntity toMember) + private void TrackCallInternal(TypeSystemEntity fromMember, TypeSystemEntity toMember) { if (!_callGraph.TryGetValue(fromMember, out HashSet? toMembers)) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedNames.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedNames.cs index 90584110173b8..9135cda60e5ac 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedNames.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedNames.cs @@ -5,7 +5,7 @@ namespace ILCompiler.Dataflow { - sealed class CompilerGeneratedNames + internal sealed class CompilerGeneratedNames { internal static bool IsGeneratedMemberName(string memberName) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs index c62233bd957a9..359ccf70cfe78 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs @@ -20,20 +20,20 @@ namespace ILCompiler.Dataflow // Currently this is implemented using heuristics public class CompilerGeneratedState { - readonly record struct TypeArgumentInfo( + private readonly record struct TypeArgumentInfo( /// The method which calls the ctor for the given type MethodDesc CreatingMethod, /// Attributes for the type, pulled from the creators type arguments IReadOnlyList? OriginalAttributes); - readonly TypeCacheHashtable _typeCacheHashtable; + private readonly TypeCacheHashtable _typeCacheHashtable; public CompilerGeneratedState(ILProvider ilProvider, Logger logger) { _typeCacheHashtable = new TypeCacheHashtable(ilProvider, logger); } - class TypeCacheHashtable : LockFreeReaderHashtable + private sealed class TypeCacheHashtable : LockFreeReaderHashtable { private ILProvider _ilProvider; private Logger? _logger; @@ -49,7 +49,7 @@ protected override TypeCache CreateValueFromKey(MetadataType key) => new TypeCache(key, _logger, _ilProvider); } - class TypeCache + private sealed class TypeCache { public readonly MetadataType Type; @@ -484,7 +484,7 @@ public bool TryGetOwningMethodForCompilerGeneratedType(MetadataType compilerGene } } - static IEnumerable GetCompilerGeneratedNestedTypes(MetadataType type) + private static IEnumerable GetCompilerGeneratedNestedTypes(MetadataType type) { foreach (var nestedType in type.GetNestedTypes()) { @@ -531,13 +531,9 @@ public static bool TryGetStateMachineType(MethodDesc method, [NotNullWhen(true)] // Discover state machine methods. if (method is not EcmaMethod ecmaMethod) return false; - - CustomAttributeValue? decodedAttribute = null; - decodedAttribute = ecmaMethod.GetDecodedCustomAttribute("System.Runtime.CompilerServices", "AsyncIteratorStateMachineAttribute"); - if (decodedAttribute == null) - decodedAttribute = ecmaMethod.GetDecodedCustomAttribute("System.Runtime.CompilerServices", "AsyncStateMachineAttribute"); - if (decodedAttribute == null) - decodedAttribute = ecmaMethod.GetDecodedCustomAttribute("System.Runtime.CompilerServices", "IteratorStateMachineAttribute"); + CustomAttributeValue? decodedAttribute = ecmaMethod.GetDecodedCustomAttribute("System.Runtime.CompilerServices", "AsyncIteratorStateMachineAttribute"); + decodedAttribute ??= ecmaMethod.GetDecodedCustomAttribute("System.Runtime.CompilerServices", "AsyncStateMachineAttribute"); + decodedAttribute ??= ecmaMethod.GetDecodedCustomAttribute("System.Runtime.CompilerServices", "IteratorStateMachineAttribute"); if (decodedAttribute == null) return false; @@ -565,7 +561,7 @@ public static bool TryGetStateMachineType(MethodDesc method, [NotNullWhen(true)] return _typeCacheHashtable.GetOrCreateValue(userType); } - static TypeDesc? GetFirstConstructorArgumentAsType(CustomAttributeValue attribute) + private static TypeDesc? GetFirstConstructorArgumentAsType(CustomAttributeValue attribute) { if (attribute.FixedArguments.Length == 0) return null; @@ -650,7 +646,7 @@ public bool TryGetUserMethodForCompilerGeneratedMember(TypeSystemEntity sourceMe return false; TypeSystemEntity member = sourceMember; - MethodDesc? userMethodCandidate = null; + MethodDesc? userMethodCandidate; while (TryGetOwningMethodForCompilerGeneratedMember(member, out userMethodCandidate)) { Debug.Assert(userMethodCandidate != member); @@ -660,7 +656,7 @@ public bool TryGetUserMethodForCompilerGeneratedMember(TypeSystemEntity sourceMe if (userMethod != null) { - Debug.Assert(!CompilerGeneratedState.IsNestedFunctionOrStateMachineMember(userMethod)); + Debug.Assert(!IsNestedFunctionOrStateMachineMember(userMethod)); return true; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/DiagnosticContext.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/DiagnosticContext.cs index 85dbe6df08497..b05470c724d32 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/DiagnosticContext.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/DiagnosticContext.cs @@ -11,11 +11,11 @@ namespace ILLink.Shared.TrimAnalysis public readonly partial struct DiagnosticContext { public readonly MessageOrigin Origin; - readonly bool _diagnosticsEnabled; - readonly bool _suppressTrimmerDiagnostics; - readonly bool _suppressAotDiagnostics; - readonly bool _suppressSingleFileDiagnostics; - readonly Logger _logger; + private readonly bool _diagnosticsEnabled; + private readonly bool _suppressTrimmerDiagnostics; + private readonly bool _suppressAotDiagnostics; + private readonly bool _suppressSingleFileDiagnostics; + private readonly Logger _logger; public DiagnosticContext(in MessageOrigin origin, bool diagnosticsEnabled, Logger logger) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/DiagnosticUtilities.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/DiagnosticUtilities.cs index 18246282ca012..3234aec87ec91 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/DiagnosticUtilities.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/DiagnosticUtilities.cs @@ -1,17 +1,15 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Reflection.Metadata; -using ILLink.Shared; using Internal.TypeSystem; using Internal.TypeSystem.Ecma; namespace ILCompiler.Dataflow { - static class DiagnosticUtilities + internal static class DiagnosticUtilities { internal static Origin GetMethodParameterFromIndex(MethodDesc method, int parameterIndex) { @@ -134,7 +132,7 @@ internal static bool IsInRequiresScope(this MethodDesc method, string requiresAt /// Doesn't check the associated symbol for overrides and virtual methods because we should warn on mismatched between the property AND the accessors /// /// - /// MethodDesc that is either an overriding member or an overridden/virtual member + /// MethodDesc that is either an overriding member or an overridden/virtual member /// internal static bool IsOverrideInRequiresScope(this MethodDesc method, string requiresAttribute) => method.IsInRequiresScope(requiresAttribute, false); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/EcmaExtensions.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/EcmaExtensions.cs index 5d91895e35711..b13bf5556eef9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/EcmaExtensions.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/EcmaExtensions.cs @@ -15,7 +15,7 @@ namespace ILCompiler.Dataflow { - static class EcmaExtensions + internal static class EcmaExtensions { public static bool IsPublic(this MethodDesc method) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FieldValue.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FieldValue.cs index 3c23fba55f5f3..d20d5962c5ecc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FieldValue.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FieldValue.cs @@ -16,7 +16,7 @@ namespace ILLink.Shared.TrimAnalysis /// /// A representation of a field. Typically a result of ldfld. /// - sealed partial record FieldValue : IValueWithStaticType + internal sealed partial record FieldValue : IValueWithStaticType { public FieldValue(FieldDesc field, DynamicallyAccessedMemberTypes dynamicallyAccessedMemberTypes) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FlowAnnotations.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FlowAnnotations.cs index 270f578fbdfd2..eaccfc76e196e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FlowAnnotations.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FlowAnnotations.cs @@ -25,7 +25,7 @@ namespace ILLink.Shared.TrimAnalysis /// /// Caches dataflow annotations for type members. /// - sealed public partial class FlowAnnotations + public sealed partial class FlowAnnotations { private readonly TypeAnnotationsHashtable _hashtable; private readonly Logger _logger; @@ -285,7 +285,7 @@ private TypeAnnotations GetAnnotations(TypeDesc type) return _hashtable.GetOrCreateValue(type); } - private class TypeAnnotationsHashtable : LockFreeReaderHashtable + private sealed class TypeAnnotationsHashtable : LockFreeReaderHashtable { private readonly ILProvider _ilProvider; private readonly Logger _logger; @@ -356,7 +356,7 @@ protected override TypeAnnotations CreateValueFromKey(TypeDesc key) // If the class hierarchy is not walkable, just stop collecting the annotations. } - var annotatedFields = new ArrayBuilder(); + var annotatedFields = default(ArrayBuilder); // First go over all fields with an explicit annotation foreach (EcmaField field in ecmaType.GetFields()) @@ -379,7 +379,7 @@ protected override TypeAnnotations CreateValueFromKey(TypeDesc key) annotatedFields.Add(new FieldAnnotation(field, annotation)); } - var annotatedMethods = new ArrayBuilder(); + var annotatedMethods = default(ArrayBuilder); // Next go over all methods with an explicit annotation foreach (EcmaMethod method in ecmaType.GetMethods()) @@ -458,10 +458,7 @@ protected override TypeAnnotations CreateValueFromKey(TypeDesc key) continue; } - if (paramAnnotations == null) - { - paramAnnotations = new DynamicallyAccessedMemberTypes[signature.Length + offset]; - } + paramAnnotations ??= new DynamicallyAccessedMemberTypes[signature.Length + offset]; paramAnnotations[parameter.SequenceNumber - 1 + offset] = pa; } } @@ -473,8 +470,7 @@ protected override TypeAnnotations CreateValueFromKey(TypeDesc key) var annotation = GetMemberTypesForDynamicallyAccessedMembersAttribute(reader, genericParameterDef.GetCustomAttributes()); if (annotation != DynamicallyAccessedMemberTypes.None) { - if (genericParameterAnnotations == null) - genericParameterAnnotations = new DynamicallyAccessedMemberTypes[method.Instantiation.Length]; + genericParameterAnnotations ??= new DynamicallyAccessedMemberTypes[method.Instantiation.Length]; genericParameterAnnotations[genericParameter.Index] = annotation; } } @@ -614,8 +610,7 @@ protected override TypeAnnotations CreateValueFromKey(TypeDesc key) var annotation = GetMemberTypesForDynamicallyAccessedMembersAttribute(reader, genericParameterDef.GetCustomAttributes()); if (annotation != DynamicallyAccessedMemberTypes.None) { - if (typeGenericParameterAnnotations == null) - typeGenericParameterAnnotations = new DynamicallyAccessedMemberTypes[ecmaType.Instantiation.Length]; + typeGenericParameterAnnotations ??= new DynamicallyAccessedMemberTypes[ecmaType.Instantiation.Length]; typeGenericParameterAnnotations[genericParameterIndex] = annotation; } } @@ -749,7 +744,7 @@ internal void ValidateMethodAnnotationsAreSame(MethodDesc method, MethodDesc bas } } - void ValidateMethodParametersHaveNoAnnotations(DynamicallyAccessedMemberTypes[] parameterAnnotations, MethodDesc method, MethodDesc baseMethod, MethodDesc origin) + private void ValidateMethodParametersHaveNoAnnotations(DynamicallyAccessedMemberTypes[] parameterAnnotations, MethodDesc method, MethodDesc baseMethod, MethodDesc origin) { for (int parameterIndex = 0; parameterIndex < parameterAnnotations.Length; parameterIndex++) { @@ -762,7 +757,7 @@ void ValidateMethodParametersHaveNoAnnotations(DynamicallyAccessedMemberTypes[] } } - void ValidateMethodGenericParametersHaveNoAnnotations(DynamicallyAccessedMemberTypes[] genericParameterAnnotations, MethodDesc method, MethodDesc baseMethod, MethodDesc origin) + private void ValidateMethodGenericParametersHaveNoAnnotations(DynamicallyAccessedMemberTypes[] genericParameterAnnotations, MethodDesc method, MethodDesc baseMethod, MethodDesc origin) { for (int genericParameterIndex = 0; genericParameterIndex < genericParameterAnnotations.Length; genericParameterIndex++) { @@ -776,7 +771,7 @@ void ValidateMethodGenericParametersHaveNoAnnotations(DynamicallyAccessedMemberT } } - void LogValidationWarning(object provider, object baseProvider, MethodDesc origin) + private void LogValidationWarning(object provider, object baseProvider, MethodDesc origin) { switch (provider) { @@ -790,7 +785,7 @@ void LogValidationWarning(object provider, object baseProvider, MethodDesc origi genericParameterOverride.Name, DiagnosticUtilities.GetGenericParameterDeclaringMemberDisplayName(new GenericParameterOrigin(genericParameterOverride)), ((GenericParameterDesc)baseProvider).Name, DiagnosticUtilities.GetGenericParameterDeclaringMemberDisplayName(new GenericParameterOrigin((GenericParameterDesc)baseProvider))); break; - case TypeDesc methodReturnType: + case TypeDesc: _logger.LogWarning(origin, DiagnosticId.DynamicallyAccessedMembersMismatchOnMethodReturnValueBetweenOverrides, DiagnosticUtilities.GetMethodSignatureDisplayName(origin), DiagnosticUtilities.GetMethodSignatureDisplayName((MethodDesc)baseProvider)); break; @@ -804,7 +799,7 @@ void LogValidationWarning(object provider, object baseProvider, MethodDesc origi } } - private class TypeAnnotations + private sealed class TypeAnnotations { public readonly TypeDesc Type; public readonly DynamicallyAccessedMemberTypes TypeAnnotation; @@ -932,7 +927,9 @@ public FieldAnnotation(FieldDesc field, DynamicallyAccessedMemberTypes annotatio internal partial bool MethodRequiresDataFlowAnalysis(MethodProxy method) => RequiresDataflowAnalysis(method.Method); +#pragma warning disable CA1822 // Other partial implementations are not in the ilc project internal partial MethodReturnValue GetMethodReturnValue(MethodProxy method, DynamicallyAccessedMemberTypes dynamicallyAccessedMemberTypes) +#pragma warning restore CA1822 // Mark members as static => new MethodReturnValue(method.Method, dynamicallyAccessedMemberTypes); internal partial MethodReturnValue GetMethodReturnValue(MethodProxy method) @@ -949,7 +946,9 @@ internal partial MethodThisParameterValue GetMethodThisParameterValue(MethodProx internal partial MethodThisParameterValue GetMethodThisParameterValue(MethodProxy method) => GetMethodThisParameterValue(method, GetParameterAnnotation(method.Method, 0)); +#pragma warning disable CA1822 // Other partial implementations are not in the ilc project internal partial MethodParameterValue GetMethodParameterValue(MethodProxy method, int parameterIndex, DynamicallyAccessedMemberTypes dynamicallyAccessedMemberTypes) +#pragma warning restore CA1822 // Mark members as static => new(method.Method, parameterIndex, dynamicallyAccessedMemberTypes); internal partial MethodParameterValue GetMethodParameterValue(MethodProxy method, int parameterIndex) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/GenericArgumentDataFlow.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/GenericArgumentDataFlow.cs index 1bdc58eee2922..071f2bed0fbaf 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/GenericArgumentDataFlow.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/GenericArgumentDataFlow.cs @@ -20,10 +20,10 @@ namespace ILCompiler.Dataflow { public readonly struct GenericArgumentDataFlow { - readonly Logger _logger; - readonly NodeFactory _factory; - readonly FlowAnnotations _annotations; - readonly MessageOrigin _origin; + private readonly Logger _logger; + private readonly NodeFactory _factory; + private readonly FlowAnnotations _annotations; + private readonly MessageOrigin _origin; public GenericArgumentDataFlow(Logger logger, NodeFactory factory, FlowAnnotations annotations, in MessageOrigin origin) { @@ -47,7 +47,7 @@ public DependencyList ProcessGenericArgumentDataFlow(GenericParameterDesc generi return RequireDynamicallyAccessedMembers(diagnosticContext, genericArgumentValue, genericParameterValue, new GenericParameterOrigin(genericParameter)); } - DependencyList RequireDynamicallyAccessedMembers( + private DependencyList RequireDynamicallyAccessedMembers( in DiagnosticContext diagnosticContext, in MultiValue value, ValueWithDynamicallyAccessedMembers targetValue, diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/GenericParameterValue.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/GenericParameterValue.cs index 423b17c54d5f1..3e7ef0550d098 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/GenericParameterValue.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/GenericParameterValue.cs @@ -15,7 +15,7 @@ namespace ILLink.Shared.TrimAnalysis /// This is a System.Type value which represents generic parameter (basically result of typeof(T)) /// Its actual type is unknown, but it can have annotations. /// - partial record GenericParameterValue + internal partial record GenericParameterValue { public GenericParameterValue(GenericParameterDesc genericParameter, DynamicallyAccessedMemberTypes dynamicallyAccessedMemberTypes) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs index e885dc796f9f5..4fdb6c2f8b9f3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs @@ -14,13 +14,13 @@ namespace ILLink.Shared.TrimAnalysis { - partial struct HandleCallAction + internal partial struct HandleCallAction { #pragma warning disable CA1822 // Mark members as static - the other partial implementations might need to be instance methods - readonly ReflectionMarker _reflectionMarker; - readonly MethodDesc _callingMethod; - readonly Origin _memberWithRequirements; + private readonly ReflectionMarker _reflectionMarker; + private readonly MethodDesc _callingMethod; + private readonly Origin _memberWithRequirements; public HandleCallAction( FlowAnnotations annotations, diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HoistedLocalKey.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HoistedLocalKey.cs index 11be949bed019..289a62232bfc8 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HoistedLocalKey.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HoistedLocalKey.cs @@ -15,7 +15,7 @@ namespace ILCompiler.Dataflow // or local functions). public readonly struct HoistedLocalKey : IEquatable { - readonly FieldDesc Field; + private readonly FieldDesc Field; public HoistedLocalKey(FieldDesc field) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/IValueWithStaticType.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/IValueWithStaticType.cs index eb08e77d0171e..85d1fe273956f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/IValueWithStaticType.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/IValueWithStaticType.cs @@ -7,7 +7,7 @@ namespace ILCompiler.Dataflow { - interface IValueWithStaticType + internal interface IValueWithStaticType { /// /// The IL type of the value, represented as closely as possible, but not always exact. It can be null, for diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/InterproceduralState.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/InterproceduralState.cs index 304fa353d69e8..d76f69fd41d3a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/InterproceduralState.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/InterproceduralState.cs @@ -20,7 +20,7 @@ namespace ILCompiler.Dataflow { // Wrapper that implements IEquatable for MethodBody. - readonly record struct MethodBodyValue(MethodIL MethodBody) : IEquatable + internal readonly record struct MethodBodyValue(MethodIL MethodBody) : IEquatable { bool IEquatable.Equals(ILCompiler.Dataflow.MethodBodyValue other) => other.MethodBody.OwningMethod == MethodBody.OwningMethod; @@ -30,12 +30,14 @@ bool IEquatable.Equals(ILCompiler.Dataflow.MethodBodyValue othe // Tracks the set of methods which get analyzer together during interprocedural analysis, // and the possible states of hoisted locals in state machine methods and lambdas/local functions. - struct InterproceduralState : IEquatable +#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable + internal struct InterproceduralState : IEquatable +#pragma warning restore CA1067 // Override Object.Equals(object) when implementing IEquatable { - readonly ILProvider _ilProvider; + private readonly ILProvider _ilProvider; public ValueSet MethodBodies; public HoistedLocalState HoistedLocals; - readonly InterproceduralStateLattice lattice; + private readonly InterproceduralStateLattice lattice; public InterproceduralState(ILProvider ilProvider, ValueSet methodBodies, HoistedLocalState hoistedLocals, InterproceduralStateLattice lattice) => (_ilProvider, MethodBodies, HoistedLocals, this.lattice) = (ilProvider, methodBodies, hoistedLocals, lattice); @@ -119,7 +121,7 @@ public void SetHoistedLocal(HoistedLocalKey key, MultiValue value) public MultiValue GetHoistedLocal(HoistedLocalKey key) => HoistedLocals.Get(key); - bool TryGetMethodBody(MethodDesc method, [NotNullWhen(true)] out MethodIL? methodBody) + private bool TryGetMethodBody(MethodDesc method, [NotNullWhen(true)] out MethodIL? methodBody) { methodBody = null; @@ -135,7 +137,7 @@ bool TryGetMethodBody(MethodDesc method, [NotNullWhen(true)] out MethodIL? metho } } - struct InterproceduralStateLattice : ILattice + internal struct InterproceduralStateLattice : ILattice { private readonly ILProvider _ilProvider; public readonly ValueSetLattice MethodBodyLattice; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodBodyScanner.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodBodyScanner.cs index 428d5658bedab..0fa9c843faf71 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodBodyScanner.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodBodyScanner.cs @@ -26,7 +26,7 @@ namespace ILCompiler.Dataflow /// /// Tracks information about the contents of a stack slot /// - readonly struct StackSlot + internal readonly struct StackSlot { public MultiValue Value { get; } @@ -46,14 +46,14 @@ public StackSlot(MultiValue value) } } - abstract partial class MethodBodyScanner + internal abstract partial class MethodBodyScanner { protected readonly InterproceduralStateLattice InterproceduralStateLattice; protected static ValueSetLattice MultiValueLattice => default; protected readonly FlowAnnotations _annotations; - internal MultiValue ReturnValue { private set; get; } + internal MultiValue ReturnValue { get; private set; } protected MethodBodyScanner(FlowAnnotations annotations) { @@ -160,10 +160,10 @@ private static void NewKnownStack(Dictionary> knownStacks, private struct BasicBlockIterator { - readonly HashSet _methodBranchTargets; - int _currentBlockIndex; - bool _foundEndOfPrevBlock; - MethodIL _methodBody; + private readonly HashSet _methodBranchTargets; + private int _currentBlockIndex; + private bool _foundEndOfPrevBlock; + private MethodIL _methodBody; public BasicBlockIterator(MethodIL methodBody) { @@ -202,7 +202,7 @@ public int MoveNext(int offset) } [Conditional("DEBUG")] - static void ValidateNoReferenceToReference(ValueBasicBlockPair?[] locals, MethodIL method, int ilOffset) + private static void ValidateNoReferenceToReference(ValueBasicBlockPair?[] locals, MethodIL method, int ilOffset) { for (int localVariableIndex = 0; localVariableIndex < locals.Length; localVariableIndex++) { @@ -241,14 +241,14 @@ private static void StoreMethodLocalValue( if (!existingValue.HasValue || existingValue.Value.BasicBlockIndex == curBasicBlock) { - // If the previous value was stored in the current basic block, then we can safely + // If the previous value was stored in the current basic block, then we can safely // overwrite the previous value with the new one. value = valueToStore; } else { - // If the previous value came from a previous basic block, then some other use of - // the local could see the previous value, so we must merge the new value with the + // If the previous value came from a previous basic block, then some other use of + // the local could see the previous value, so we must merge the new value with the // old value. value = MultiValueLattice.Meet(existingValue.Value.Value, valueToStore); } @@ -269,14 +269,14 @@ private static void StoreMethodLocalValue( if (existingValue.BasicBlockIndex == curBasicBlock) { - // If the previous value was stored in the current basic block, then we can safely + // If the previous value was stored in the current basic block, then we can safely // overwrite the previous value with the new one. value = valueToStore; } else { - // If the previous value came from a previous basic block, then some other use of - // the local could see the previous value, so we must merge the new value with the + // If the previous value came from a previous basic block, then some other use of + // the local could see the previous value, so we must merge the new value with the // old value. value = MultiValueLattice.Meet(existingValue.Value, valueToStore); } @@ -328,7 +328,7 @@ public virtual void InterproceduralScan(MethodIL startingMethodBody) // Disabled asserts due to a bug // Debug.Assert (interproceduralState.Count == 1 + calleeMethods.Count ()); // foreach (var method in calleeMethods) - // Debug.Assert (interproceduralState.Any (kvp => kvp.Key.Method == method)); + // Debug.Assert (interproceduralState.Any (kvp => kvp.Key.Method == method)); } else { @@ -337,7 +337,7 @@ public virtual void InterproceduralScan(MethodIL startingMethodBody) #endif } - void TrackNestedFunctionReference(MethodDesc referencedMethod, ref InterproceduralState interproceduralState) + private static void TrackNestedFunctionReference(MethodDesc referencedMethod, ref InterproceduralState interproceduralState) { MethodDesc method = referencedMethod.GetTypicalMethodDefinition(); @@ -360,7 +360,7 @@ protected virtual void Scan(MethodIL methodBody, ref InterproceduralState interp BasicBlockIterator blockIterator = new BasicBlockIterator(methodBody); - ReturnValue = new(); + ReturnValue = default(MultiValue); ILReader reader = new ILReader(methodBody.GetILBytes()); while (reader.HasNext) { @@ -380,10 +380,7 @@ protected virtual void Scan(MethodIL methodBody, ref InterproceduralState interp } } - if (currentStack == null) - { - currentStack = new Stack(methodBody.MaxStack); - } + currentStack ??= new Stack(methodBody.MaxStack); int offset = reader.Offset; ILOpcode opcode = reader.ReadILOpcode(); @@ -790,7 +787,7 @@ protected virtual void Scan(MethodIL methodBody, ref InterproceduralState interp { StackSlot retValue = PopUnknown(currentStack, 1, methodBody, offset); // If the return value is a reference, treat it as the value itself for now - // We can handle ref return values better later + // We can handle ref return values better later ReturnValue = MultiValueLattice.Meet(ReturnValue, DereferenceValue(retValue.Value, locals, ref interproceduralState)); } ClearStack(ref currentStack); @@ -899,7 +896,7 @@ Stack currentStack // If the targetValue is MethodThisValue do nothing - it should never happen really, and if it does, there's nothing we can track there } - private void ScanLdloc( + private static void ScanLdloc( MethodIL methodBody, int offset, ILOpcode operation, diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodParameterValue.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodParameterValue.cs index b8e5e72803084..939774bdbb093 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodParameterValue.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodParameterValue.cs @@ -15,7 +15,7 @@ namespace ILLink.Shared.TrimAnalysis /// /// A value that came from a method parameter - such as the result of a ldarg. /// - partial record MethodParameterValue : IValueWithStaticType + internal partial record MethodParameterValue : IValueWithStaticType { public MethodParameterValue(MethodDesc method, int parameterIndex, DynamicallyAccessedMemberTypes dynamicallyAccessedMemberTypes) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodProxy.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodProxy.cs index 4795258de4a15..10bc11748a8e0 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodProxy.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodProxy.cs @@ -12,7 +12,7 @@ namespace ILLink.Shared.TypeSystemProxy { - readonly partial struct MethodProxy : IEquatable + internal readonly partial struct MethodProxy : IEquatable { public MethodProxy(MethodDesc method) => Method = method; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodReturnValue.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodReturnValue.cs index 552e971a059e3..2162383cfb574 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodReturnValue.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodReturnValue.cs @@ -14,7 +14,7 @@ namespace ILLink.Shared.TrimAnalysis /// /// Return value from a method /// - partial record MethodReturnValue : IValueWithStaticType + internal partial record MethodReturnValue : IValueWithStaticType { public MethodReturnValue(MethodDesc method, DynamicallyAccessedMemberTypes dynamicallyAccessedMemberTypes) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodThisParameterValue.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodThisParameterValue.cs index b04698e26d07a..4597849963ba9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodThisParameterValue.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodThisParameterValue.cs @@ -16,7 +16,7 @@ namespace ILLink.Shared.TrimAnalysis /// /// A value that came from the implicit this parameter of a method /// - partial record MethodThisParameterValue : IValueWithStaticType + internal partial record MethodThisParameterValue : IValueWithStaticType { public MethodThisParameterValue(MethodDesc method, DynamicallyAccessedMemberTypes dynamicallyAccessedMemberTypes) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/Origin.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/Origin.cs index 2668a4696cc5e..13b6cf85447e8 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/Origin.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/Origin.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Internal.TypeSystem; -using Internal.TypeSystem.Ecma; namespace ILCompiler.Dataflow { @@ -10,7 +9,7 @@ internal abstract class Origin { } - class MethodReturnOrigin : Origin + internal sealed class MethodReturnOrigin : Origin { public MethodDesc Method { get; } @@ -22,7 +21,7 @@ public MethodReturnOrigin(MethodDesc method) public string GetDisplayName() => Method.GetDisplayName(); } - class ParameterOrigin : Origin + internal sealed class ParameterOrigin : Origin { public MethodDesc Method { get; } public int Index { get; } @@ -36,7 +35,7 @@ public ParameterOrigin(MethodDesc method, int index) public string GetDisplayName() => Method.GetDisplayName(); } - class MethodOrigin : Origin + internal sealed class MethodOrigin : Origin { public MethodDesc Method { get; } @@ -48,7 +47,7 @@ public MethodOrigin(MethodDesc method) public string GetDisplayName() => Method.GetDisplayName(); } - class FieldOrigin : Origin + internal sealed class FieldOrigin : Origin { public FieldDesc Field { get; } @@ -60,7 +59,7 @@ public FieldOrigin(FieldDesc field) public string GetDisplayName() => Field.GetDisplayName(); } - class TypeOrigin : Origin + internal sealed class TypeOrigin : Origin { public MetadataType Type { get; } @@ -72,7 +71,7 @@ public TypeOrigin(MetadataType type) public string GetDisplayName() => Type.GetDisplayName(); } - class GenericParameterOrigin : Origin + internal sealed class GenericParameterOrigin : Origin { public GenericParameterDesc GenericParameter { get; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMarker.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMarker.cs index c20596b08e45f..79ee807c27d6e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMarker.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMarker.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.ComponentModel.DataAnnotations; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Reflection; @@ -74,7 +73,7 @@ internal bool TryResolveTypeNameAndMark(string typeName, in DiagnosticContext di // NativeAOT doesn't have a fully capable type name resolver yet // Once this is implemented don't forget to wire up marking of type forwards which are used in generic parameters - if (!ILCompiler.DependencyAnalysis.ReflectionMethodBodyScanner.ResolveType(typeName, callingModule, diagnosticContext.Origin.MemberDefinition!.Context, out TypeDesc foundType, out ModuleDesc referenceModule)) + if (!DependencyAnalysis.ReflectionMethodBodyScanner.ResolveType(typeName, callingModule, diagnosticContext.Origin.MemberDefinition!.Context, out TypeDesc foundType, out ModuleDesc referenceModule)) { type = default; return false; @@ -111,7 +110,7 @@ internal void MarkMethod(in MessageOrigin origin, MethodDesc method, Origin memb RootingHelpers.TryGetDependenciesForReflectedMethod(ref _dependencies, Factory, method, memberWithRequirements.ToString()); } - void MarkField(in MessageOrigin origin, FieldDesc field, Origin memberWithRequirements) + private void MarkField(in MessageOrigin origin, FieldDesc field, Origin memberWithRequirements) { if (!_enabled) return; @@ -132,7 +131,7 @@ internal void MarkProperty(in MessageOrigin origin, PropertyPseudoDesc property, MarkMethod(origin, property.SetMethod, memberWithRequirements); } - void MarkEvent(in MessageOrigin origin, EventPseudoDesc @event, Origin memberWithRequirements) + private void MarkEvent(in MessageOrigin origin, EventPseudoDesc @event, Origin memberWithRequirements) { if (!_enabled) return; @@ -192,7 +191,7 @@ internal void MarkStaticConstructor(in MessageOrigin origin, TypeDesc type) } } - void CheckAndWarnOnReflectionAccess(in MessageOrigin origin, TypeSystemEntity entity, Origin memberWithRequirements) + private void CheckAndWarnOnReflectionAccess(in MessageOrigin origin, TypeSystemEntity entity, Origin memberWithRequirements) { if (entity.DoesMemberRequire(DiagnosticUtilities.RequiresUnreferencedCodeAttribute, out CustomAttributeValue? requiresAttribute)) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMethodBodyScanner.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMethodBodyScanner.cs index c6c3705b9551a..3f075847110cd 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMethodBodyScanner.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMethodBodyScanner.cs @@ -2,23 +2,15 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; -using System.Reflection; -using System.Reflection.Metadata; using ILCompiler.Logging; using ILLink.Shared; -using ILLink.Shared.DataFlow; using ILLink.Shared.TrimAnalysis; -using ILLink.Shared.TypeSystemProxy; using Internal.IL; using Internal.TypeSystem; - -using CustomAttributeNamedArgumentKind = System.Reflection.Metadata.CustomAttributeNamedArgumentKind; -using CustomAttributeValue = System.Reflection.Metadata.CustomAttributeValue; using DependencyList = ILCompiler.DependencyAnalysisFramework.DependencyNodeCore.DependencyList; using InteropTypes = Internal.TypeSystem.Interop.InteropTypes; using MultiValue = ILLink.Shared.DataFlow.ValueSet; @@ -29,7 +21,7 @@ namespace ILCompiler.Dataflow { - sealed class ReflectionMethodBodyScanner : MethodBodyScanner + internal sealed class ReflectionMethodBodyScanner : MethodBodyScanner { private readonly Logger _logger; private readonly NodeFactory _factory; @@ -144,7 +136,7 @@ protected override void WarnAboutInvalidILInMethod(MethodIL method, int ilOffset protected override ValueWithDynamicallyAccessedMembers GetMethodParameterValue(MethodDesc method, int parameterIndex) => GetMethodParameterValue(method, parameterIndex, _annotations.GetParameterAnnotation(method, parameterIndex)); - ValueWithDynamicallyAccessedMembers GetMethodParameterValue(MethodDesc method, int parameterIndex, DynamicallyAccessedMemberTypes dynamicallyAccessedMemberTypes) + private ValueWithDynamicallyAccessedMembers GetMethodParameterValue(MethodDesc method, int parameterIndex, DynamicallyAccessedMemberTypes dynamicallyAccessedMemberTypes) { if (!method.Signature.IsStatic) { @@ -183,7 +175,6 @@ protected override void HandleStoreMethodReturnValue(MethodIL methodBody, int of public override bool HandleCall(MethodIL callingMethodBody, MethodDesc calledMethod, ILOpcode operation, int offset, ValueNodeList methodParams, out MultiValue methodReturnValue) { - methodReturnValue = null; Debug.Assert(callingMethodBody.OwningMethod == _origin.MemberDefinition); _origin = _origin.WithInstructionOffset(callingMethodBody, offset); @@ -570,14 +561,14 @@ void AddReturnValue(MultiValue value) } } - static bool IsAotUnsafeDelegate(TypeDesc parameterType) + private static bool IsAotUnsafeDelegate(TypeDesc parameterType) { TypeSystemContext context = parameterType.Context; return parameterType.IsWellKnownType(Internal.TypeSystem.WellKnownType.MulticastDelegate) || parameterType == context.GetWellKnownType(Internal.TypeSystem.WellKnownType.MulticastDelegate).BaseType; } - static bool IsComInterop(MarshalAsDescriptor? marshalInfoProvider, TypeDesc parameterType) + private static bool IsComInterop(MarshalAsDescriptor? marshalInfoProvider, TypeDesc parameterType) { // This is best effort. One can likely find ways how to get COM without triggering these alarms. // AsAny marshalling of a struct with an object-typed field would be one, for example. @@ -656,7 +647,7 @@ static bool IsComInterop(MarshalAsDescriptor? marshalInfoProvider, TypeDesc para return false; } - void HandleAssignmentPattern( + private void HandleAssignmentPattern( in MessageOrigin origin, in MultiValue value, ValueWithDynamicallyAccessedMembers targetValue, diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/RequireDynamicallyAccessedMembersAction.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/RequireDynamicallyAccessedMembersAction.cs index 0b6abdb478fae..b4eb5fa48eec1 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/RequireDynamicallyAccessedMembersAction.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/RequireDynamicallyAccessedMembersAction.cs @@ -10,10 +10,10 @@ namespace ILLink.Shared.TrimAnalysis { - partial struct RequireDynamicallyAccessedMembersAction + internal partial struct RequireDynamicallyAccessedMembersAction { - readonly ReflectionMarker _reflectionMarker; - readonly Origin _memberWithRequirements; + private readonly ReflectionMarker _reflectionMarker; + private readonly Origin _memberWithRequirements; public RequireDynamicallyAccessedMembersAction( ReflectionMarker reflectionMarker, diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ScannerExtensions.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ScannerExtensions.cs index 4a63effd60802..df87273214673 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ScannerExtensions.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ScannerExtensions.cs @@ -1,13 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using Internal.IL; -using Internal.TypeSystem; - -using Debug = System.Diagnostics.Debug; namespace ILCompiler.Dataflow { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/TrimAnalysisPatternStore.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/TrimAnalysisPatternStore.cs index e728a5599ff85..44ff8eabf39ab 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/TrimAnalysisPatternStore.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/TrimAnalysisPatternStore.cs @@ -12,10 +12,10 @@ namespace ILCompiler.Dataflow { public readonly struct TrimAnalysisPatternStore { - readonly Dictionary<(MessageOrigin, bool), TrimAnalysisAssignmentPattern> AssignmentPatterns; - readonly Dictionary MethodCallPatterns; - readonly ValueSetLattice Lattice; - readonly Logger _logger; + private readonly Dictionary<(MessageOrigin, bool), TrimAnalysisAssignmentPattern> AssignmentPatterns; + private readonly Dictionary MethodCallPatterns; + private readonly ValueSetLattice Lattice; + private readonly Logger _logger; public TrimAnalysisPatternStore(ValueSetLattice lattice, Logger logger) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/TypeExtensions.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/TypeExtensions.cs index d8a0311b5a663..8109b19732ff8 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/TypeExtensions.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/TypeExtensions.cs @@ -2,10 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections; using ILLink.Shared.TypeSystemProxy; using Internal.TypeSystem; -using Internal.TypeSystem.Ecma; using TypeSystemWellKnownType = Internal.TypeSystem.WellKnownType; using ILLinkSharedWellKnownType = ILLink.Shared.TypeSystemProxy.WellKnownType; @@ -14,7 +12,7 @@ namespace ILCompiler.Dataflow { - static class TypeExtensions + internal static class TypeExtensions { public static bool IsTypeOf(this TypeDesc type, string ns, string name) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ValueNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ValueNode.cs index 8e22a0c9fc96f..f18186d768b04 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ValueNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ValueNode.cs @@ -28,7 +28,7 @@ public ValueNodeList(List other) public override int GetHashCode() { - HashCode hashCode = new HashCode(); + HashCode hashCode = default(HashCode); foreach (var item in this) hashCode.Add(item.GetHashCode()); return hashCode.ToHashCode(); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ArrayOfEmbeddedDataNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ArrayOfEmbeddedDataNode.cs index bc6a93c776aef..beaa6c24c357e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ArrayOfEmbeddedDataNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ArrayOfEmbeddedDataNode.cs @@ -1,12 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; -using System.Diagnostics; -using System.Text; -using ILCompiler.DependencyAnalysisFramework; -using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis { @@ -31,7 +26,7 @@ public ArrayOfEmbeddedDataNode(string startSymbolMangledName, string endSymbolMa { _sorter = nodeSorter; } - + public void AddEmbeddedObject(TEmbedded symbol) { lock (_nestedNodes) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ArrayOfEmbeddedPointersNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ArrayOfEmbeddedPointersNode.cs index 2d426c40a6296..ba9e73eccfbfe 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ArrayOfEmbeddedPointersNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ArrayOfEmbeddedPointersNode.cs @@ -43,7 +43,7 @@ public EmbeddedObjectNode NewNodeWithSymbol(TTarget target) return new EmbeddedPointerIndirectionWithSymbolNode(this, target, GetNextId()); } - int GetNextId() + private int GetNextId() { return System.Threading.Interlocked.Increment(ref _nextId); } @@ -52,7 +52,7 @@ int GetNextId() public override int ClassCode => (int)ObjectNodeOrder.ArrayOfEmbeddedPointersNode; - private class PointerIndirectionNodeComparer : IComparer> + private sealed class PointerIndirectionNodeComparer : IComparer> { private IComparer _innerComparer; @@ -98,7 +98,7 @@ public override IEnumerable GetStaticDependencies(NodeFacto public override int ClassCode => -66002498; } - private class EmbeddedPointerIndirectionWithSymbolNode : SimpleEmbeddedPointerIndirectionNode, ISymbolDefinitionNode + private sealed class EmbeddedPointerIndirectionWithSymbolNode : SimpleEmbeddedPointerIndirectionNode, ISymbolDefinitionNode { private int _id; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ArrayOfFrozenObjectsNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ArrayOfFrozenObjectsNode.cs index e2bc6c4b70ec8..b6d8ba5147f4b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ArrayOfFrozenObjectsNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ArrayOfFrozenObjectsNode.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using Internal.TypeSystem; @@ -15,7 +14,7 @@ public ArrayOfFrozenObjectsNode(string startSymbolMangledName, string endSymbolM { } - private void AlignNextObject(ref ObjectDataBuilder builder, NodeFactory factory) + private static void AlignNextObject(ref ObjectDataBuilder builder, NodeFactory factory) { builder.EmitZeros(AlignmentHelper.AlignUp(builder.CountBytes, factory.Target.PointerSize) - builder.CountBytes); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/BlobNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/BlobNode.cs index 9e9a393c8f82d..bee1c395219f8 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/BlobNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/BlobNode.cs @@ -4,7 +4,6 @@ using System; using Internal.Text; -using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/BlockReflectionTypeMapNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/BlockReflectionTypeMapNode.cs index 0020d0581f243..184ab830eaf8c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/BlockReflectionTypeMapNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/BlockReflectionTypeMapNode.cs @@ -61,10 +61,10 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) if (!factory.MetadataManager.IsReflectionBlocked(mdType)) continue; - + if (!factory.CompilationModuleGroup.ContainsType(mdType)) continue; - + // Go with a necessary type symbol. It will be upgraded to a constructed one if a constructed was emitted. IEETypeNode typeSymbol = factory.NecessaryTypeSymbol(type); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CallingConventionConverterKey.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CallingConventionConverterKey.cs index 40b7281dbba01..bad73673193be 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CallingConventionConverterKey.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CallingConventionConverterKey.cs @@ -98,7 +98,7 @@ public override void AppendName(StringBuilder sb, GenericParameterDesc type) public override void AppendName(StringBuilder sb, SignatureTypeVariable type) { - sb.Append("!"); + sb.Append('!'); sb.Append(type.Index.ToStringInvariant()); } @@ -177,7 +177,7 @@ protected override void AppendNameForNamespaceType(StringBuilder sb, DefType typ } } - private void AppendAssemblyName(StringBuilder sb, IAssemblyDesc assembly) + private static void AppendAssemblyName(StringBuilder sb, IAssemblyDesc assembly) { if (assembly == null) return; @@ -201,18 +201,18 @@ protected override void AppendNameForNestedType(StringBuilder sb, DefType nested AppendEscapedIdentifier(sb, GetTypeName(nestedType)); } - private string GetTypeName(DefType type) + private static string GetTypeName(DefType type) { return type.Name; } - private string GetTypeNamespace(DefType type) + private static string GetTypeNamespace(DefType type) { return type.Namespace; } private static char[] s_escapedChars = new char[] { ',', '=', '"', ']', '[', '*', '&', '+', '\\' }; - private void AppendEscapedIdentifier(StringBuilder sb, string identifier) + private static void AppendEscapedIdentifier(StringBuilder sb, string identifier) { if (identifier.IndexOfAny(s_escapedChars) < 0) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CanonicalDefinitionEETypeNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CanonicalDefinitionEETypeNode.cs index a598bfe9961f1..6d6050c5eb272 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CanonicalDefinitionEETypeNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CanonicalDefinitionEETypeNode.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; using System.Diagnostics; using Internal.TypeSystem; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CanonicalEETypeNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CanonicalEETypeNode.cs index 772f2ed66d99d..90555997d7e65 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CanonicalEETypeNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CanonicalEETypeNode.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; using System.Diagnostics; using Internal.TypeSystem; @@ -13,8 +11,8 @@ namespace ILCompiler.DependencyAnalysis /// /// Canonical type instantiations are emitted, not because they are used directly by the user code, but because /// they are used by the dynamic type loader when dynamically instantiating types at runtime. - /// The data that we emit on canonical type instantiations should just be the minimum that is needed by the template - /// type loader. + /// The data that we emit on canonical type instantiations should just be the minimum that is needed by the template + /// type loader. /// Similarly, the dependencies that we track for canonical type instantiations are minimal, and are just the ones used /// by the dynamic type loader /// @@ -109,7 +107,7 @@ protected override void OutputGCDesc(ref ObjectDataBuilder builder) protected override void OutputInterfaceMap(NodeFactory factory, ref ObjectDataBuilder objData) { - foreach (var itf in _type.RuntimeInterfaces) + for (int i = 0; i < _type.RuntimeInterfaces.Length; i++) { // Interface omitted for canonical instantiations (constructed at runtime for dynamic types from the native layout info) objData.EmitZeroPointer(); @@ -126,7 +124,7 @@ protected override int BaseSize if (instanceByteCount.IsIndeterminate) { - // For USG types, they may be of indeterminate size, and the size of the type may be meaningless. + // For USG types, they may be of indeterminate size, and the size of the type may be meaningless. // In that case emit a fixed constant. return MinimumObjectSize; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ClassConstructorContextMap.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ClassConstructorContextMap.cs index db7e7b2c35378..f8c39f2a61a93 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ClassConstructorContextMap.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ClassConstructorContextMap.cs @@ -11,7 +11,7 @@ namespace ILCompiler.DependencyAnalysis { - class ClassConstructorContextMap : ObjectNode, ISymbolDefinitionNode + internal sealed class ClassConstructorContextMap : ObjectNode, ISymbolDefinitionNode { private ObjectAndOffsetSymbolNode _endSymbol; private ExternalReferencesTableNode _externalReferences; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CodeBasedDependencyAlgorithm.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CodeBasedDependencyAlgorithm.cs index a879d035d1706..df54d26e3199a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CodeBasedDependencyAlgorithm.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CodeBasedDependencyAlgorithm.cs @@ -1,17 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Diagnostics; - using Internal.IL; -using Internal.Text; using Internal.TypeSystem; -using ILCompiler.DependencyAnalysisFramework; - -using DependencyList=ILCompiler.DependencyAnalysisFramework.DependencyNodeCore.DependencyList; -using CombinedDependencyList=System.Collections.Generic.List.CombinedDependencyListEntry>; -using DependencyListEntry=ILCompiler.DependencyAnalysisFramework.DependencyNodeCore.DependencyListEntry; +using DependencyList = ILCompiler.DependencyAnalysisFramework.DependencyNodeCore.DependencyList; +using CombinedDependencyList = System.Collections.Generic.List.CombinedDependencyListEntry>; namespace ILCompiler.DependencyAnalysis @@ -57,7 +51,7 @@ public static void AddDependenciesDueToMethodCodePresence(ref DependencyList dep if (templateDependencies != null) { - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); foreach (TypeDesc templateType in templateDependencies) { dependencies.Add(factory.NativeLayout.TemplateTypeLayout(templateType), "Generic comparer"); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ConstructedEETypeNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ConstructedEETypeNode.cs index 10d5aa6b31df4..01205d68e86aa 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ConstructedEETypeNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ConstructedEETypeNode.cs @@ -1,12 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Generic; using System.Diagnostics; using Internal.Runtime; using Internal.TypeSystem; -using Internal.IL; namespace ILCompiler.DependencyAnalysis { @@ -66,11 +64,11 @@ protected override DependencyList ComputeNonRelocationBasedDependencies(NodeFact { if (instantiationType.IsValueType) { - // All valuetype generic parameters of a constructed type may be effectively constructed. This is generally not that + // All valuetype generic parameters of a constructed type may be effectively constructed. This is generally not that // critical, but in the presence of universal generics the compiler may generate a Box followed by calls to ToString, // GetHashcode or Equals in ways that cannot otherwise be detected by dependency analysis. Thus force all struct type // generic parameters to be considered constructed when walking dependencies of a constructed generic - dependencyList.Add(factory.ConstructedTypeSymbol(instantiationType.ConvertToCanonForm(CanonicalFormKind.Specific)), + dependencyList.Add(factory.ConstructedTypeSymbol(instantiationType.ConvertToCanonForm(CanonicalFormKind.Specific)), "Struct generic parameters in constructed types may be assumed to be used as constructed in constructed generic types"); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs index 3ce2085c08a71..3265e501a8cec 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs @@ -17,7 +17,7 @@ namespace ILCompiler.DependencyAnalysis /// Computes the list of dependencies that are necessary to generate metadata for a custom attribute, but also the dependencies to /// make the custom attributes usable by the reflection stack at runtime. /// - internal class CustomAttributeBasedDependencyAlgorithm + internal static class CustomAttributeBasedDependencyAlgorithm { public static void AddDependenciesDueToCustomAttributes(ref DependencyList dependencies, NodeFactory factory, EcmaMethod method) { @@ -133,7 +133,7 @@ private static void AddDependenciesDueToCustomAttributes(ref DependencyList depe if (AddDependenciesFromCustomAttributeBlob(caDependencies, factory, constructor.OwningType, decodedValue)) { - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); dependencies.AddRange(caDependencies); dependencies.Add(factory.CustomAttributeMetadata(new ReflectableCustomAttribute(module, caHandle)), "Attribute metadata"); } @@ -156,8 +156,6 @@ private static void AddDependenciesDueToCustomAttributes(ref DependencyList depe private static bool AddDependenciesFromCustomAttributeBlob(DependencyList dependencies, NodeFactory factory, TypeDesc attributeType, CustomAttributeValue value) { - MetadataManager mdManager = factory.MetadataManager; - foreach (CustomAttributeTypedArgument decodedArgument in value.FixedArguments) { if (!AddDependenciesFromCustomAttributeArgument(dependencies, factory, decodedArgument.Type, decodedArgument.Value)) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeMetadataNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeMetadataNode.cs index 9cb52e99ebb71..7b4706cde57ba 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeMetadataNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeMetadataNode.cs @@ -5,10 +5,6 @@ using ILCompiler.DependencyAnalysisFramework; -using Internal.TypeSystem; - -using Debug = System.Diagnostics.Debug; - namespace ILCompiler.DependencyAnalysis { /// @@ -17,7 +13,7 @@ namespace ILCompiler.DependencyAnalysis /// /// Only expected to be used during ILScanning when scanning for reflection. /// - internal class CustomAttributeMetadataNode : DependencyNodeCore + internal sealed class CustomAttributeMetadataNode : DependencyNodeCore { private readonly ReflectableCustomAttribute _customAttribute; @@ -35,7 +31,7 @@ public CustomAttributeMetadataNode(ReflectableCustomAttribute customAttribute) // We need to walk the dependencies before placing the node into the graph to find out whether // the attribute even can be generated (does it refer to blocked types or something like that?). public override IEnumerable GetStaticDependencies(NodeFactory factory) => null; - + protected override string GetName(NodeFactory factory) { return $"Reflectable custom attribute {_customAttribute.CustomAttributeHandle} in {_customAttribute.Module}"; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DataflowAnalyzedMethodNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DataflowAnalyzedMethodNode.cs index 2935553dba001..07f34d58a1829 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DataflowAnalyzedMethodNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DataflowAnalyzedMethodNode.cs @@ -6,7 +6,6 @@ using System.Diagnostics; using Internal.TypeSystem; -using Internal.Runtime; using Internal.IL; using ILCompiler.Dataflow; @@ -27,7 +26,7 @@ public DataflowAnalyzedMethodNode(MethodIL methodIL) Debug.Assert(!CompilerGeneratedState.IsNestedFunctionOrStateMachineMember(methodIL.OwningMethod)); _methodIL = methodIL; } - + public override IEnumerable GetStaticDependencies(NodeFactory factory) { var mdManager = (UsageBasedMetadataManager)factory.MetadataManager; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DefaultConstructorMapNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DefaultConstructorMapNode.cs index 01e18fd982403..c1603a87ad105 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DefaultConstructorMapNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DefaultConstructorMapNode.cs @@ -2,22 +2,18 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Diagnostics; -using System.Collections.Generic; using Internal.Text; using Internal.TypeSystem; using Internal.NativeFormat; -using ILCompiler.DependencyAnalysisFramework; - namespace ILCompiler.DependencyAnalysis { /// - /// DefaultConstructorMap blob, containing information on default constructor entrypoints of all types used + /// DefaultConstructorMap blob, containing information on default constructor entrypoints of all types used /// by lazy generic instantiations. /// - internal class DefaultConstructorMapNode : ObjectNode, ISymbolDefinitionNode + internal sealed class DefaultConstructorMapNode : ObjectNode, ISymbolDefinitionNode { private ObjectAndOffsetSymbolNode _endSymbol; private ExternalReferencesTableNode _externalReferences; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DictionaryLayoutNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DictionaryLayoutNode.cs index 26ddc6da9a13b..d0faaf570c423 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DictionaryLayoutNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DictionaryLayoutNode.cs @@ -88,7 +88,7 @@ public virtual int GetSlotForFixedEntry(GenericLookupResult entry) { return GetSlotForEntry(entry); } - + public abstract IEnumerable Entries { get; @@ -113,7 +113,7 @@ public abstract bool HasFixedSlots public virtual ICollection GetTemplateEntries(NodeFactory factory) { - ArrayBuilder templateEntries = new ArrayBuilder(); + ArrayBuilder templateEntries = default(ArrayBuilder); foreach (var entry in Entries) { templateEntries.Add(entry.TemplateDictionaryNode(factory)); @@ -182,7 +182,7 @@ public override IEnumerable GetConditionalStaticDep return conditionalDependencies; } - protected override string GetName(NodeFactory factory) => $"Dictionary layout for {_owningMethodOrType.ToString()}"; + protected override string GetName(NodeFactory factory) => $"Dictionary layout for {_owningMethodOrType}"; public override bool HasConditionalStaticDependencies => HasFixedSlots; public override bool HasDynamicDependencies => false; @@ -201,7 +201,7 @@ public class PrecomputedDictionaryLayoutNode : DictionaryLayoutNode public PrecomputedDictionaryLayoutNode(TypeSystemEntity owningMethodOrType, IEnumerable layout) : base(owningMethodOrType) { - ArrayBuilder l = new ArrayBuilder(); + ArrayBuilder l = default(ArrayBuilder); foreach (var entry in layout) l.Add(entry); @@ -243,10 +243,10 @@ public override IEnumerable Entries public sealed class LazilyBuiltDictionaryLayoutNode : DictionaryLayoutNode { - class EntryHashTable : LockFreeReaderHashtable + private sealed class EntryHashTable : LockFreeReaderHashtable { - protected override bool CompareKeyToValue(GenericLookupResult key, GenericLookupResult value) => Object.Equals(key, value); - protected override bool CompareValueToValue(GenericLookupResult value1, GenericLookupResult value2) => Object.Equals(value1, value2); + protected override bool CompareKeyToValue(GenericLookupResult key, GenericLookupResult value) => Equals(key, value); + protected override bool CompareValueToValue(GenericLookupResult value1, GenericLookupResult value2) => Equals(value1, value2); protected override GenericLookupResult CreateValueFromKey(GenericLookupResult key) => key; protected override int GetKeyHashCode(GenericLookupResult key) => key.GetHashCode(); protected override int GetValueHashCode(GenericLookupResult value) => value.GetHashCode(); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DynamicDependencyAttributeAlgorithm.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DynamicDependencyAttributeAlgorithm.cs index 4e3afab67672f..aa5f4f0630f2f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DynamicDependencyAttributeAlgorithm.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DynamicDependencyAttributeAlgorithm.cs @@ -1,11 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using System.Reflection.Metadata; using Internal.TypeSystem; using Internal.TypeSystem.Ecma; @@ -15,7 +13,6 @@ using static ILCompiler.Dataflow.DynamicallyAccessedMembersBinder; using DependencyList = ILCompiler.DependencyAnalysisFramework.DependencyNodeCore.DependencyList; -using MethodAttributes = System.Reflection.MethodAttributes; namespace ILCompiler.DependencyAnalysis { @@ -23,7 +20,7 @@ namespace ILCompiler.DependencyAnalysis /// Computes the list of dependencies from DynamicDependencyAttribute. /// https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.dynamicdependencyattribute /// - internal class DynamicDependencyAttributeAlgorithm + internal static class DynamicDependencyAttributeAlgorithm { public static void AddDependenciesDueToDynamicDependencyAttribute(ref DependencyList dependencies, NodeFactory factory, EcmaMethod method) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs index a74192ec04512..9c7b103af1461 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs @@ -660,12 +660,12 @@ private void OutputComponentSize(ref ObjectDataBuilder objData) private void OutputFlags(NodeFactory factory, ref ObjectDataBuilder objData) { - UInt16 flags = EETypeBuilderHelpers.ComputeFlags(_type); + ushort flags = EETypeBuilderHelpers.ComputeFlags(_type); if (_type.GetTypeDefinition() == factory.ArrayOfTEnumeratorType) { // Generic array enumerators use special variance rules recognized by the runtime - flags |= (UInt16)EETypeFlags.GenericVarianceFlag; + flags |= (ushort)EETypeFlags.GenericVarianceFlag; } if (factory.TypeSystemContext.IsGenericArrayInterfaceType(_type)) @@ -673,12 +673,12 @@ private void OutputFlags(NodeFactory factory, ref ObjectDataBuilder objData) // Runtime casting logic relies on all interface types implemented on arrays // to have the variant flag set (even if all the arguments are non-variant). // This supports e.g. casting uint[] to ICollection - flags |= (UInt16)EETypeFlags.GenericVarianceFlag; + flags |= (ushort)EETypeFlags.GenericVarianceFlag; } if (_type.IsIDynamicInterfaceCastable) { - flags |= (UInt16)EETypeFlags.IDynamicInterfaceCastableFlag; + flags |= (ushort)EETypeFlags.IDynamicInterfaceCastableFlag; } ISymbolNode relatedTypeNode = GetRelatedTypeNode(factory); @@ -688,17 +688,17 @@ private void OutputFlags(NodeFactory factory, ref ObjectDataBuilder objData) // that it should indirect through the import address table if (relatedTypeNode != null && relatedTypeNode.RepresentsIndirectionCell) { - flags |= (UInt16)EETypeFlags.RelatedTypeViaIATFlag; + flags |= (ushort)EETypeFlags.RelatedTypeViaIATFlag; } if (HasOptionalFields) { - flags |= (UInt16)EETypeFlags.OptionalFieldsFlag; + flags |= (ushort)EETypeFlags.OptionalFieldsFlag; } if (this is ClonedConstructedEETypeNode) { - flags |= (UInt16)EETypeKind.ClonedEEType; + flags |= (ushort)EETypeKind.ClonedEEType; } objData.EmitShort((short)flags); @@ -1050,7 +1050,7 @@ protected internal virtual void ComputeOptionalEETypeFields(NodeFactory factory, ComputeValueTypeFieldPadding(); } - void ComputeRareFlags(NodeFactory factory, bool relocsOnly) + private void ComputeRareFlags(NodeFactory factory, bool relocsOnly) { uint flags = 0; @@ -1102,7 +1102,7 @@ void ComputeRareFlags(NodeFactory factory, bool relocsOnly) /// To support boxing / unboxing, the offset of the value field of a Nullable type is recorded on the MethodTable. /// This is variable according to the alignment requirements of the Nullable<T> type parameter. /// - void ComputeNullableValueOffset() + private void ComputeNullableValueOffset() { if (!_type.IsNullable) return; @@ -1194,8 +1194,7 @@ public static void AddDependenciesForStaticsNode(NodeFactory factory, TypeDesc t if (factory.TypeSystemContext.SupportsUniversalCanon || (factory.TypeSystemContext.SupportsCanon && (type != type.ConvertToCanonForm(CanonicalFormKind.Specific)))) { - if (dependencies == null) - dependencies = new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(factory.NecessaryTypeSymbol(type), "Static block owning type is necessary for canonically equivalent reflection"); } @@ -1221,8 +1220,7 @@ protected static void AddDependenciesForUniversalGVMSupport(NodeFactory factory, MethodDesc universalCanonMethodNonCanonicalized = method.MakeInstantiatedMethod(new Instantiation(universalCanonArray)); MethodDesc universalCanonGVMMethod = universalCanonMethodNonCanonicalized.GetCanonMethodTarget(CanonicalFormKind.Universal); - if (dependencies == null) - dependencies = new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(new DependencyListEntry(factory.MethodEntrypoint(universalCanonGVMMethod), "USG GVM Method")); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeOptionalFieldsNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeOptionalFieldsNode.cs index aa6d25c8c82ac..fbde550ed54fd 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeOptionalFieldsNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeOptionalFieldsNode.cs @@ -1,11 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Diagnostics; - using Internal.Text; -using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis { @@ -58,7 +54,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) _owner.ComputeOptionalEETypeFields(factory, relocsOnly: false); objData.EmitBytes(_owner.GetOptionalFieldsData()); } - + return objData.ToObjectData(); } @@ -66,7 +62,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) public override int CompareToImpl(ISortableNode other, CompilerComparer comparer) { - return SortableDependencyNode.CompareImpl(_owner, ((EETypeOptionalFieldsNode)other)._owner, comparer); + return CompareImpl(_owner, ((EETypeOptionalFieldsNode)other)._owner, comparer); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EmbeddedPointerIndirectionNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EmbeddedPointerIndirectionNode.cs index 7b3664ffbc6e6..4dd52258d2084 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EmbeddedPointerIndirectionNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EmbeddedPointerIndirectionNode.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using Internal.Text; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EmbeddedTrimmingDescriptorNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EmbeddedTrimmingDescriptorNode.cs index b71403a1c9a69..0aeb11b5fc69c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EmbeddedTrimmingDescriptorNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EmbeddedTrimmingDescriptorNode.cs @@ -24,7 +24,7 @@ public EmbeddedTrimmingDescriptorNode(EcmaModule module) { _module = module; } - + public override IEnumerable GetStaticDependencies(NodeFactory factory) { PEMemoryBlock resourceDirectory = _module.PEReader.GetSectionData(_module.PEReader.PEHeaders.CorHeader.ResourcesDirectory.RelativeVirtualAddress); @@ -60,7 +60,7 @@ public override IEnumerable GetStaticDependencies(NodeFacto protected override string GetName(NodeFactory factory) { - return $"Embedded descriptor from {_module.ToString()}"; + return $"Embedded descriptor from {_module}"; } public override bool InterestingForDynamicDependencyAnalysis => false; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExactMethodInstantiationsNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExactMethodInstantiationsNode.cs index 1635f4d07b560..c91124338a746 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExactMethodInstantiationsNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExactMethodInstantiationsNode.cs @@ -109,7 +109,7 @@ public static void GetExactMethodInstantiationDependenciesForMethod(ref Dependen if (!IsMethodEligibleForTracking(factory, method)) return; - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); // Method entry point dependency bool getUnboxingStub = method.OwningType.IsValueType && !method.Signature.IsStatic; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternSymbolNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternSymbolNode.cs index 721e983ef5640..ca02f10f177de 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternSymbolNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternSymbolNode.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using ILCompiler.DependencyAnalysisFramework; @@ -14,7 +13,7 @@ namespace ILCompiler.DependencyAnalysis /// Represents a symbol that is defined externally and statically linked to the output obj file. /// public class ExternSymbolNode : SortableDependencyNode, ISortableSymbolNode - { + { private readonly Utf8String _name; private readonly bool _isIndirection; @@ -24,7 +23,7 @@ public ExternSymbolNode(Utf8String name, bool isIndirection = false) _isIndirection = isIndirection; } - protected override string GetName(NodeFactory factory) => $"ExternSymbol {_name.ToString()}{(_isIndirection ? " (indirected)" : "")}"; + protected override string GetName(NodeFactory factory) => $"ExternSymbol {_name}{(_isIndirection ? " (indirected)" : "")}"; public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternSymbolsImportedNodeProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternSymbolsImportedNodeProvider.cs index 18668be9769bb..2af223e880fc0 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternSymbolsImportedNodeProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternSymbolsImportedNodeProvider.cs @@ -2,11 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using ILCompiler.DependencyAnalysisFramework; using Internal.TypeSystem; -using Debug = System.Diagnostics.Debug; namespace ILCompiler.DependencyAnalysis { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternalReferencesTableNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternalReferencesTableNode.cs index 393ea936f240a..2cbd2b03a0987 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternalReferencesTableNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternalReferencesTableNode.cs @@ -5,8 +5,6 @@ using System.Collections.Generic; using Internal.Text; -using Internal.TypeSystem; -using Internal.Runtime; using Debug = System.Diagnostics.Debug; @@ -109,7 +107,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) } _endSymbol.SetSymbolOffset(builder.CountBytes); - + builder.AddSymbol(this); builder.AddSymbol(_endSymbol); @@ -123,7 +121,7 @@ public override int CompareToImpl(ISortableNode other, CompilerComparer comparer return string.Compare(_blobName, ((ExternalReferencesTableNode)other)._blobName); } - struct SymbolAndDelta : IEquatable + private struct SymbolAndDelta : IEquatable { public readonly ISymbolNode Symbol; public readonly int Delta; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FatFunctionPointerNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FatFunctionPointerNode.cs index 2dd04047e594e..a4622553d4c9e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FatFunctionPointerNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FatFunctionPointerNode.cs @@ -86,7 +86,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) // The next entry is a pointer to the context to be used for the canonical method builder.EmitPointerReloc(contextParameter); - + return builder.ToObjectData(); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FieldMetadataNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FieldMetadataNode.cs index 603f7c7068fdc..8cf60ae0f293e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FieldMetadataNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FieldMetadataNode.cs @@ -18,7 +18,7 @@ namespace ILCompiler.DependencyAnalysis /// /// Only expected to be used during ILScanning when scanning for reflection. /// - internal class FieldMetadataNode : DependencyNodeCore + internal sealed class FieldMetadataNode : DependencyNodeCore { private readonly FieldDesc _field; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FieldRvaDataNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FieldRvaDataNode.cs index d1f9e3e580060..243a4cd225b9a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FieldRvaDataNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FieldRvaDataNode.cs @@ -14,7 +14,7 @@ namespace ILCompiler.DependencyAnalysis public class FieldRvaDataNode : ObjectNode, ISymbolDefinitionNode { private readonly EcmaField _field; - + public FieldRvaDataNode(EcmaField field) { Debug.Assert(field.HasRva); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FrozenObjectNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FrozenObjectNode.cs index 567ecb7595c51..7e036c8692c09 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FrozenObjectNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FrozenObjectNode.cs @@ -18,7 +18,7 @@ public class FrozenObjectNode : EmbeddedObjectNode, ISymbolDefinitionNode private readonly MetadataType _owningType; private readonly TypePreinit.ISerializableReference _data; private readonly int _allocationSiteId; - + public FrozenObjectNode(MetadataType owningType, int allocationSiteId, TypePreinit.ISerializableReference data) { _owningType = owningType; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GCStaticEETypeNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GCStaticEETypeNode.cs index 653e7c378c826..da28ef9d54577 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GCStaticEETypeNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GCStaticEETypeNode.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Text; using Internal.Runtime; using Internal.Text; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GCStaticsNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GCStaticsNode.cs index 929314cd7763f..08e706b527cd2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GCStaticsNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GCStaticsNode.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Generic; - using Internal.Text; using Internal.TypeSystem; @@ -89,7 +87,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) bool isPreinitialized = _preinitializationInfo != null && _preinitializationInfo.IsPreinitialized; if (isPreinitialized) delta |= GCStaticRegionConstants.HasPreInitializedData; - + builder.EmitPointerReloc(GetGCStaticEETypeNode(factory), delta); if (isPreinitialized) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GCStaticsPreInitDataNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GCStaticsPreInitDataNode.cs index d84317c8002e2..1514c8a1ce7ca 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GCStaticsPreInitDataNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GCStaticsPreInitDataNode.cs @@ -68,7 +68,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) { if (!field.IsStatic || field.HasRva || field.IsLiteral || field.IsThreadStatic || !field.HasGCStaticBase) continue; - + int padding = field.Offset.AsInt - initialOffset - builder.CountBytes; Debug.Assert(padding >= 0); builder.EmitZeros(padding); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GVMDependenciesNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GVMDependenciesNode.cs index e13378f6b8ecc..af6556e41762b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GVMDependenciesNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GVMDependenciesNode.cs @@ -1,12 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Diagnostics; using System.Collections.Generic; using ILCompiler.DependencyAnalysisFramework; -using Internal.Text; using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis @@ -59,7 +57,7 @@ public override IEnumerable GetStaticDependencies(NodeFacto } bool getUnboxingStub = _method.OwningType.IsValueType; - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(context.MethodEntrypoint(_method, getUnboxingStub), "GVM Dependency - Canon method"); if (_method.IsSharedByGenericInstantiations) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericCompositionNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericCompositionNode.cs index 9857c633784db..0e17ad61b3b2f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericCompositionNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericCompositionNode.cs @@ -77,7 +77,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) builder.RequireInitialPointerAlignment(); - builder.EmitShort((short)checked((UInt16)_details.Instantiation.Length)); + builder.EmitShort((short)checked((ushort)_details.Instantiation.Length)); builder.EmitByte((byte)(hasVariance ? 1 : 0)); @@ -116,7 +116,7 @@ internal struct GenericCompositionDetails : IEquatable true; public sealed override bool IsShareable => true; @@ -104,7 +104,7 @@ public override void AppendMangledName(NameMangler nameMangler, Utf8StringBuilde protected override int HeaderSize => 0; public override Instantiation TypeInstantiation => _owningType.Instantiation; - public override Instantiation MethodInstantiation => new Instantiation(); + public override Instantiation MethodInstantiation => default(Instantiation); protected override TypeSystemContext Context => _owningType.Context; public override TypeSystemEntity OwningEntity => _owningType; public TypeDesc OwningType => _owningType; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericLookupResult.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericLookupResult.cs index cba6ebe4c2cdf..43b64f3b0817e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericLookupResult.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericLookupResult.cs @@ -4,8 +4,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; - -using Internal.IL; using Internal.Text; using Internal.TypeSystem; @@ -1360,7 +1358,6 @@ public override ISymbolNode GetTarget(NodeFactory factory, GenericLookupResultCo public override void EmitDictionaryEntry(ref ObjectDataBuilder builder, NodeFactory factory, GenericLookupResultContext dictionary, GenericDictionaryNode dictionaryNode) { - TypeDesc instantiatedType = _type.GetNonRuntimeDeterminedTypeFromRuntimeDeterminedSubtypeViaSubstitution(dictionary.TypeInstantiation, dictionary.MethodInstantiation); int typeSize; if (_type.IsDefType) @@ -1411,9 +1408,9 @@ protected override bool EqualsImpl(GenericLookupResult obj) internal sealed class ConstrainedMethodUseLookupResult : GenericLookupResult { - MethodDesc _constrainedMethod; - TypeDesc _constraintType; - bool _directCall; + private MethodDesc _constrainedMethod; + private TypeDesc _constraintType; + private bool _directCall; protected override int ClassCode => -1525377658; @@ -1547,7 +1544,7 @@ protected override bool EqualsImpl(GenericLookupResult obj) public sealed class IntegerLookupResult : GenericLookupResult { - int _integerValue; + private int _integerValue; public IntegerLookupResult(int integer) { @@ -1611,7 +1608,7 @@ public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupR public sealed class PointerToSlotLookupResult : GenericLookupResult { - int _slotIndex; + private int _slotIndex; public PointerToSlotLookupResult(int slotIndex) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericMethodsHashtableNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericMethodsHashtableNode.cs index 85ace207c8600..c033f44fd1280 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericMethodsHashtableNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericMethodsHashtableNode.cs @@ -42,7 +42,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) if (relocsOnly) return new ObjectData(Array.Empty(), Array.Empty(), 1, new ISymbolDefinitionNode[] { this }); - // Ensure the native layout data has been saved, in order to get valid Vertex offsets for the signature Vertices + // Ensure the native layout data has been saved, in order to get valid Vertex offsets for the signature Vertices factory.MetadataManager.NativeLayoutInfo.SaveNativeLayoutInfoWriter(factory); NativeWriter nativeWriter = new NativeWriter(); @@ -100,7 +100,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) public static void GetGenericMethodsHashtableDependenciesForMethod(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { Debug.Assert(method.HasInstantiation && !method.IsCanonicalMethod(CanonicalFormKind.Any)); - + // Method's containing type IEETypeNode containingTypeNode = factory.NecessaryTypeSymbol(method.OwningType); dependencies.Add(new DependencyListEntry(containingTypeNode, "GenericMethodsHashtable entry containing type")); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericMethodsTemplateMap.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericMethodsTemplateMap.cs index a34b49a88151c..2c07dc30adff2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericMethodsTemplateMap.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericMethodsTemplateMap.cs @@ -83,7 +83,7 @@ public static void GetTemplateMethodDependencies(ref DependencyList dependencies if (!IsEligibleToBeATemplate(method)) return; - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(new DependencyListEntry(factory.NativeLayout.TemplateMethodEntry(method), "Template Method Entry")); dependencies.Add(new DependencyListEntry(factory.NativeLayout.TemplateMethodLayout(method), "Template Method Layout")); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericTypesTemplateMap.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericTypesTemplateMap.cs index 150190833d2c1..f398a8cc519b8 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericTypesTemplateMap.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericTypesTemplateMap.cs @@ -5,7 +5,6 @@ using System.Diagnostics; using Internal.Text; -using ILCompiler.DependencyAnalysisFramework; using Internal.TypeSystem; using Internal.NativeFormat; @@ -80,7 +79,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) return new ObjectData(streamBytes, Array.Empty(), 1, new ISymbolDefinitionNode[] { this, _endSymbol }); } - + public static void GetTemplateTypeDependencies(ref DependencyList dependencies, NodeFactory factory, TypeDesc type) { TypeDesc templateType = ConvertArrayOfTToRegularArray(factory, type); @@ -88,7 +87,7 @@ public static void GetTemplateTypeDependencies(ref DependencyList dependencies, if (!IsEligibleToHaveATemplate(templateType)) return; - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(new DependencyListEntry(factory.NecessaryTypeSymbol(templateType), "Template type")); dependencies.Add(new DependencyListEntry(factory.NativeLayout.TemplateTypeLayout(templateType), "Template Type Layout")); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ILScanNodeFactory.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ILScanNodeFactory.cs index 25912caeb15df..58c570ffe0843 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ILScanNodeFactory.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ILScanNodeFactory.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/INodeWithCodeInfo.Aot.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/INodeWithCodeInfo.Aot.cs index b11a5819ca34f..942a097e00e31 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/INodeWithCodeInfo.Aot.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/INodeWithCodeInfo.Aot.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace ILCompiler.DependencyAnalysis { public interface INodeWithCodeInfo diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/INodeWithDebugInfo.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/INodeWithDebugInfo.cs index bf195f0170d69..97563feff21a1 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/INodeWithDebugInfo.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/INodeWithDebugInfo.cs @@ -23,7 +23,7 @@ public NativeSequencePoint(int nativeOffset, string fileName, int lineNumber, in ColNumber = colNumber; } } - + public interface INodeWithDebugInfo { bool IsStateMachineMoveNextMethod { get; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ISpecialUnboxThunkNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ISpecialUnboxThunkNode.cs index 1afba71128bc2..af444ca99e7f5 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ISpecialUnboxThunkNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ISpecialUnboxThunkNode.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Internal.TypeSystem; - namespace ILCompiler.DependencyAnalysis { /// diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ImportedNodeProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ImportedNodeProvider.cs index 5b2ac08a8bbd7..9433faa12d09f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ImportedNodeProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ImportedNodeProvider.cs @@ -2,11 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using ILCompiler.DependencyAnalysisFramework; using Internal.TypeSystem; -using Debug = System.Diagnostics.Debug; namespace ILCompiler.DependencyAnalysis { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/IndirectionExtensions.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/IndirectionExtensions.cs index c23ae00dd29d8..26102d18873e3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/IndirectionExtensions.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/IndirectionExtensions.cs @@ -2,13 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. using Internal.Runtime; -using Internal.TypeSystem; - -using Debug = System.Diagnostics.Debug; namespace ILCompiler.DependencyAnalysis { - static class IndirectionExtensions + internal static class IndirectionExtensions { /// /// Use this api to generate a reloc to a symbol that may be an indirection cell or not as a pointer @@ -27,7 +24,7 @@ public static void EmitPointerRelocOrIndirectionReference(ref this ObjectDataBui public static void EmitRelativeRelocOrIndirectionReference(ref this ObjectDataBuilder builder, ISymbolNode symbol, int delta = 0, int indirectionBit = IndirectionConstants.IndirectionCellPointer) { if (symbol.RepresentsIndirectionCell) - delta = delta | indirectionBit; + delta |= indirectionBit; builder.EmitReloc(symbol, RelocType.IMAGE_REL_BASED_RELPTR32, delta); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceDispatchCellNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceDispatchCellNode.cs index fd0e943802f04..b1b7fc8ad7ec7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceDispatchCellNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceDispatchCellNode.cs @@ -106,9 +106,9 @@ public override void EncodeData(ref ObjectDataBuilder objData, NodeFactory facto if (objData.TargetPointerSize == 8) { - // IMAGE_REL_BASED_RELPTR is a 32-bit relocation. However, the cell needs a full pointer + // IMAGE_REL_BASED_RELPTR is a 32-bit relocation. However, the cell needs a full pointer // width there since a pointer to the cache will be written into the cell. Emit additional - // 32 bits on targets whose pointer size is 64 bit. + // 32 bits on targets whose pointer size is 64 bit. objData.EmitInt(0); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceDispatchCellSectionNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceDispatchCellSectionNode.cs index 13cdd42590982..f83a168e08895 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceDispatchCellSectionNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceDispatchCellSectionNode.cs @@ -26,7 +26,7 @@ protected override void GetElementDataForNodes(ref ObjectDataBuilder builder, No if (relocsOnly) return; - // The interface dispatch cell has an alignment requirement of 2 * [Pointer size] as part of the + // The interface dispatch cell has an alignment requirement of 2 * [Pointer size] as part of the // synchronization mechanism of the two values in the runtime. builder.RequireInitialAlignment(factory.Target.PointerSize * 2); @@ -90,7 +90,7 @@ protected override void GetElementDataForNodes(ref ObjectDataBuilder builder, No /// /// Comparer that groups interface dispatch cells by their slot number. /// - private class DispatchCellComparer : IComparer + private sealed class DispatchCellComparer : IComparer { private readonly NodeFactory _factory; private readonly TypeSystemComparer _comparer = TypeSystemComparer.Instance; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceDispatchMapNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceDispatchMapNode.cs index dd183cd1b54f3..4390f46cfa9f5 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceDispatchMapNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceDispatchMapNode.cs @@ -17,7 +17,7 @@ public class InterfaceDispatchMapNode : ObjectNode, ISymbolDefinitionNode, ISort public InterfaceDispatchMapNode(NodeFactory factory, TypeDesc type) { - // Multidimensional arrays should not get a sealed vtable or a dispatch map. Runtime should use the + // Multidimensional arrays should not get a sealed vtable or a dispatch map. Runtime should use the // sealed vtable and dispatch map of the System.Array basetype instead. // Pointer arrays also follow the same path Debug.Assert(!type.IsArrayTypeWithoutGenericInterfaces()); @@ -48,7 +48,7 @@ public override ObjectNodeSection Section return ObjectNodeSection.DataSection; } } - + protected override DependencyList ComputeNonRelocationBasedDependencies(NodeFactory factory) { var result = new DependencyList(); @@ -137,7 +137,7 @@ public static bool MightHaveInterfaceDispatchMap(TypeDesc type, NodeFactory fact return false; } - void EmitDispatchMap(ref ObjectDataBuilder builder, NodeFactory factory) + private void EmitDispatchMap(ref ObjectDataBuilder builder, NodeFactory factory) { var entryCountReservation = builder.ReserveShort(); var defaultEntryCountReservation = builder.ReserveShort(); @@ -165,7 +165,7 @@ void EmitDispatchMap(ref ObjectDataBuilder builder, NodeFactory factory) Debug.Assert(interfaceType.IsInterface); IReadOnlyList virtualSlots = factory.VTable(interfaceType).Slots; - + for (int interfaceMethodSlot = 0; interfaceMethodSlot < virtualSlots.Count; interfaceMethodSlot++) { MethodDesc declMethod = virtualSlots[interfaceMethodSlot]; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceGenericVirtualMethodTableNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceGenericVirtualMethodTableNode.cs index 247ed24cc12cc..1f99e62ed3dfa 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceGenericVirtualMethodTableNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceGenericVirtualMethodTableNode.cs @@ -43,7 +43,7 @@ public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) /// /// Helper method to compute the dependencies that would be needed by a hashtable entry for an interface GVM call. - /// This helper is used by the TypeGVMEntriesNode, which is used by the dependency analysis to compute the + /// This helper is used by the TypeGVMEntriesNode, which is used by the dependency analysis to compute the /// GVM hashtable entries for the compiled types. /// The dependencies returned from this function will be reported as static dependencies of the TypeGVMEntriesNode, /// which we create for each type that has generic virtual methods. @@ -58,7 +58,7 @@ public static void GetGenericVirtualMethodImplementationDependencies(ref Depende var openCallingMethodNameAndSig = factory.NativeLayout.MethodNameAndSignatureVertex(openCallingMethod); dependencies.Add(new DependencyListEntry(factory.NativeLayout.PlacedSignatureVertex(openCallingMethodNameAndSig), "interface gvm table calling method signature")); - + // Implementation could be null if this is a default interface method reabstraction or diamond. We need to record those. if (implementationMethod != null) { @@ -97,7 +97,7 @@ private void AddGenericVirtualMethodImplementation(NodeFactory factory, MethodDe // If the implementation method is implementing some interface method, compute which // interface explicitly implemented on the type that the current method implements an interface method for. - // We need this because at runtime, the interfaces explicitly implemented on the type will have + // We need this because at runtime, the interfaces explicitly implemented on the type will have // runtime-determined signatures that we can use to make generic substitutions and check for interface matching. if (!openImplementationType.IsInterface) { @@ -105,7 +105,7 @@ private void AddGenericVirtualMethodImplementation(NodeFactory factory, MethodDe _interfaceImpls[openImplementationMethod] = new Dictionary>(); if (!_interfaceImpls[openImplementationMethod].ContainsKey(openImplementationType)) _interfaceImpls[openImplementationMethod][openImplementationType] = new HashSet(); - + int numIfacesAdded = 0; for (int index = 0; index < openImplementationType.RuntimeInterfaces.Length; index++) { @@ -190,10 +190,10 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) Debug.Assert(_interfaceImpls.ContainsKey(impl)); var ifaceImpls = _interfaceImpls[impl]; - + // First, emit how many types have method implementations for this interface method entry vertex = nativeFormatWriter.GetTuple(vertex, nativeFormatWriter.GetUnsignedConstant((uint)ifaceImpls.Count)); - + // Emit each type that implements the interface method, and the interface signatures for the interfaces implemented by the type foreach (var currentImpl in ifaceImpls) { @@ -201,7 +201,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) typeId = _externalReferences.GetIndex(factory.NecessaryTypeSymbol(implementationType)); vertex = nativeFormatWriter.GetTuple(vertex, nativeFormatWriter.GetUnsignedConstant(typeId)); - + // Emit information on which interfaces the current method entry provides implementations for vertex = nativeFormatWriter.GetTuple(vertex, nativeFormatWriter.GetUnsignedConstant((uint)currentImpl.Value.Count)); foreach (var ifaceId in currentImpl.Value) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/JumpStubNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/JumpStubNode.cs index 976f7d27e96d3..89b28978f9278 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/JumpStubNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/JumpStubNode.cs @@ -14,7 +14,7 @@ public ISymbolNode Target return _target; } } - + public JumpStubNode(ISymbolNode target) { _target = target; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MetadataNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MetadataNode.cs index 427c67f93cdbe..1ffe42a8a1cbd 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MetadataNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MetadataNode.cs @@ -4,7 +4,6 @@ using System; using Internal.Text; -using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis { @@ -14,7 +13,7 @@ namespace ILCompiler.DependencyAnalysis /// public sealed class MetadataNode : ObjectNode, ISymbolDefinitionNode { - ObjectAndOffsetSymbolNode _endSymbol; + private ObjectAndOffsetSymbolNode _endSymbol; public MetadataNode() { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MethodAssociatedDataNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MethodAssociatedDataNode.cs index d0f445af76419..8cd6b03b56302 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MethodAssociatedDataNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MethodAssociatedDataNode.cs @@ -6,7 +6,6 @@ using Internal.Text; using Internal.TypeSystem; -using Internal.TypeSystem.Interop; namespace ILCompiler.DependencyAnalysis { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MethodExceptionHandlingInfoNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MethodExceptionHandlingInfoNode.cs index d2f867d5ee296..5d76d571e3710 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MethodExceptionHandlingInfoNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MethodExceptionHandlingInfoNode.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Diagnostics; using Internal.Text; @@ -53,4 +52,3 @@ public override int CompareToImpl(ISortableNode other, CompilerComparer comparer #endif } } - diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MethodMetadataNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MethodMetadataNode.cs index 427b589090fae..723f9e08552a2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MethodMetadataNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MethodMetadataNode.cs @@ -18,7 +18,7 @@ namespace ILCompiler.DependencyAnalysis /// /// Only expected to be used during ILScanning when scanning for reflection. /// - internal class MethodMetadataNode : DependencyNodeCore + internal sealed class MethodMetadataNode : DependencyNodeCore { private readonly MethodDesc _method; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ModuleInitializerListNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ModuleInitializerListNode.cs index 888de7a5d9ffe..a88d3893e6697 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ModuleInitializerListNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ModuleInitializerListNode.cs @@ -10,7 +10,7 @@ namespace ILCompiler.DependencyAnalysis { - internal class ModuleInitializerListNode : ObjectNode, ISymbolDefinitionNode + internal sealed class ModuleInitializerListNode : ObjectNode, ISymbolDefinitionNode { private readonly ObjectAndOffsetSymbolNode _endSymbol; @@ -41,7 +41,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) // This is a summary node that doesn't introduce dependencies. if (relocsOnly) return new ObjectData(Array.Empty(), Array.Empty(), 1, new ISymbolDefinitionNode[] { this }); - + var modulesWithCctor = new List(); foreach (var methodNode in factory.MetadataManager.GetCompiledMethodBodies()) @@ -152,7 +152,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) public override int ClassCode => 0x4732738; - private class ModuleGraphNode + private sealed class ModuleGraphNode { private readonly ModuleGraphFactory _factory; private readonly ModuleDesc[] _edges; @@ -168,7 +168,7 @@ public ModuleGraphNode[] Edges return _edgeNodes; } - var edgeNodes = new ArrayBuilder(); + var edgeNodes = default(ArrayBuilder); foreach (var edge in _edges) edgeNodes.Add(_factory.GetNode(edge)); return _edgeNodes = edgeNodes.ToArray(); @@ -185,7 +185,7 @@ public ModuleGraphNode(ModuleGraphFactory factory, ModuleDesc module, ModuleDesc => (_factory, Module, _edges) = (factory, module, edges); } - private class ModuleGraphFactory + private sealed class ModuleGraphFactory { private readonly Dictionary _nodes = new Dictionary(); @@ -196,7 +196,7 @@ public ModuleGraphNode GetNode(ModuleDesc module) if (module is EcmaModule ecmaModule) { - ArrayBuilder referencedAssemblies = new ArrayBuilder(); + ArrayBuilder referencedAssemblies = default(ArrayBuilder); var reader = ecmaModule.MetadataReader; foreach (var assemblyReferenceHandle in reader.AssemblyReferences) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ModuleMetadataNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ModuleMetadataNode.cs index 3f6318bae2896..aefc5ea2e9351 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ModuleMetadataNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ModuleMetadataNode.cs @@ -18,7 +18,7 @@ namespace ILCompiler.DependencyAnalysis /// /// Only expected to be used during ILScanning when scanning for reflection. /// - internal class ModuleMetadataNode : DependencyNodeCore + internal sealed class ModuleMetadataNode : DependencyNodeCore { private readonly ModuleDesc _module; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ModuleUseBasedDependencyAlgorithm.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ModuleUseBasedDependencyAlgorithm.cs index e5e217f87efaf..c5409e8d882ce 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ModuleUseBasedDependencyAlgorithm.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ModuleUseBasedDependencyAlgorithm.cs @@ -7,7 +7,7 @@ namespace ILCompiler.DependencyAnalysis { - internal class ModuleUseBasedDependencyAlgorithm + internal static class ModuleUseBasedDependencyAlgorithm { internal static void AddDependenciesDueToModuleUse(ref DependencyList dependencyList, NodeFactory factory, ModuleDesc module) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ModulesSectionNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ModulesSectionNode.cs index 05d83408ae4b7..b48421341ad94 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ModulesSectionNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ModulesSectionNode.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.Text; using Internal.TypeSystem; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NativeLayoutInfoNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NativeLayoutInfoNode.cs index c7f4bb4ecc06a..03a231ec518d1 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NativeLayoutInfoNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NativeLayoutInfoNode.cs @@ -6,7 +6,6 @@ using Internal.Text; using Internal.NativeFormat; -using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NativeLayoutVertexNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NativeLayoutVertexNode.cs index d3e4ec3077912..d4afc43b132f3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NativeLayoutVertexNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NativeLayoutVertexNode.cs @@ -13,15 +13,15 @@ namespace ILCompiler.DependencyAnalysis { /// - /// Wrapper nodes for native layout vertex structures. These wrapper nodes are "abstract" as they do not + /// Wrapper nodes for native layout vertex structures. These wrapper nodes are "abstract" as they do not /// generate any data. They are used to keep track of the dependency nodes required by a Vertex structure. - /// + /// /// Any node in the graph that references data in the native layout blob needs to create one of these /// NativeLayoutVertexNode nodes, and track it as a dependency of itself. - /// Example: MethodCodeNodes that are saved to the table in the ExactMethodInstantiationsNode reference + /// Example: MethodCodeNodes that are saved to the table in the ExactMethodInstantiationsNode reference /// signatures stored in the native layout blob, so a NativeLayoutPlacedSignatureVertexNode node is created /// and returned as a static dependency of the associated MethodCodeNode (in the GetStaticDependencies API). - /// + /// /// Each NativeLayoutVertexNode that gets marked in the graph will register itself with the NativeLayoutInfoNode, /// so that the NativeLayoutInfoNode can write it later to the native layout blob during the call to its GetData API. /// @@ -66,17 +66,17 @@ protected NativeWriter GetNativeWriter(NodeFactory factory) /// /// Any NativeLayoutVertexNode that needs to expose the native layout Vertex after it has been saved /// needs to derive from this NativeLayoutSavedVertexNode class. - /// + /// /// A nativelayout Vertex should typically only be exposed for Vertex offset fetching purposes, after the native /// writer is saved (Vertex offsets get generated when the native writer gets saved). - /// + /// /// It is important for whoever derives from this class to produce unified Vertices. Calling the WriteVertex method /// multiple times should always produce the same exact unified Vertex each time (hence the assert in SetSavedVertex). /// All nativewriter.Getxyz methods return unified Vertices. - /// - /// When exposing a saved Vertex that is a result of a section placement operation (Section.Place(...)), always make - /// sure a unified Vertex is being placed in the section (Section.Place creates a PlacedVertex structure that wraps the - /// Vertex to be placed, so if the Vertex to be placed is unified, there will only be a single unified PlacedVertex + /// + /// When exposing a saved Vertex that is a result of a section placement operation (Section.Place(...)), always make + /// sure a unified Vertex is being placed in the section (Section.Place creates a PlacedVertex structure that wraps the + /// Vertex to be placed, so if the Vertex to be placed is unified, there will only be a single unified PlacedVertex /// structure created for that placed Vertex). /// public abstract class NativeLayoutSavedVertexNode : NativeLayoutVertexNode @@ -84,7 +84,7 @@ public abstract class NativeLayoutSavedVertexNode : NativeLayoutVertexNode public Vertex SavedVertex { get; private set; } protected Vertex SetSavedVertex(Vertex value) { - Debug.Assert(SavedVertex == null || Object.ReferenceEquals(SavedVertex, value)); + Debug.Assert(SavedVertex == null || ReferenceEquals(SavedVertex, value)); SavedVertex = value; return value; } @@ -148,8 +148,7 @@ public override IEnumerable GetStaticDependencies(NodeFacto if ((_flags & MethodEntryFlags.SaveEntryPoint) != 0) { - bool unboxingStub; - IMethodNode methodEntryPointNode = GetMethodEntrypointNode(context, out unboxingStub); + IMethodNode methodEntryPointNode = GetMethodEntrypointNode(context, out _); dependencies.Add(new DependencyListEntry(methodEntryPointNode, "NativeLayoutMethodEntryVertexNode entrypoint")); } @@ -431,7 +430,7 @@ public static NativeLayoutTypeSignatureVertexNode NewTypeSignatureVertexNode(Nod } } - sealed class NativeLayoutParameterizedTypeSignatureVertexNode : NativeLayoutTypeSignatureVertexNode + private sealed class NativeLayoutParameterizedTypeSignatureVertexNode : NativeLayoutTypeSignatureVertexNode { private NativeLayoutVertexNode _parameterTypeSig; @@ -475,7 +474,7 @@ public override Vertex WriteVertex(NodeFactory factory) } } - sealed class NativeLayoutGenericVarSignatureVertexNode : NativeLayoutTypeSignatureVertexNode + private sealed class NativeLayoutGenericVarSignatureVertexNode : NativeLayoutTypeSignatureVertexNode { public NativeLayoutGenericVarSignatureVertexNode(NodeFactory factory, TypeDesc type) : base(type) { @@ -502,7 +501,7 @@ public override Vertex WriteVertex(NodeFactory factory) } } - sealed class NativeLayoutInstantiatedTypeSignatureVertexNode : NativeLayoutTypeSignatureVertexNode + private sealed class NativeLayoutInstantiatedTypeSignatureVertexNode : NativeLayoutTypeSignatureVertexNode { private NativeLayoutTypeSignatureVertexNode _genericTypeDefSig; private NativeLayoutTypeSignatureVertexNode[] _instantiationArgs; @@ -540,7 +539,7 @@ public override Vertex WriteVertex(NodeFactory factory) } } - sealed class NativeLayoutEETypeSignatureVertexNode : NativeLayoutTypeSignatureVertexNode + private sealed class NativeLayoutEETypeSignatureVertexNode : NativeLayoutTypeSignatureVertexNode { public NativeLayoutEETypeSignatureVertexNode(NodeFactory factory, TypeDesc type) : base(type) { @@ -616,9 +615,9 @@ public override Vertex WriteVertex(NodeFactory factory) // This vertex doesn't need to assert as marked, as it simply represents the concept of an existing vertex which has been placed. // Always use the NativeLayoutInfo blob for names and sigs, even if the associated types/methods are written elsewhere. - // This saves space, since we can Unify more signatures, allows optimizations in comparing sigs in the same module, and - // prevents the dynamic type loader having to know about other native layout sections (since sigs contain types). If we are - // using a non-native layout info writer, write the sig to the native layout info, and refer to it by offset in its own + // This saves space, since we can Unify more signatures, allows optimizations in comparing sigs in the same module, and + // prevents the dynamic type loader having to know about other native layout sections (since sigs contain types). If we are + // using a non-native layout info writer, write the sig to the native layout info, and refer to it by offset in its own // section. At runtime, we will assume all names and sigs are in the native layout and find it. Vertex signature = _signatureToBePlaced.WriteVertex(factory); @@ -757,9 +756,8 @@ public sealed class NativeLayoutDictionarySignatureNode : NativeLayoutSavedVerte private TypeSystemEntity _owningMethodOrType; public NativeLayoutDictionarySignatureNode(NodeFactory nodeFactory, TypeSystemEntity owningMethodOrType) { - if (owningMethodOrType is MethodDesc) + if (owningMethodOrType is MethodDesc owningMethod) { - MethodDesc owningMethod = (MethodDesc)owningMethodOrType; Debug.Assert(owningMethod.IsCanonicalMethod(CanonicalFormKind.Universal) || nodeFactory.LazyGenericsPolicy.UsesLazyGenerics(owningMethod)); Debug.Assert(owningMethod.IsCanonicalMethod(CanonicalFormKind.Any)); Debug.Assert(owningMethod.HasInstantiation); @@ -776,9 +774,8 @@ public NativeLayoutDictionarySignatureNode(NodeFactory nodeFactory, TypeSystemEn private GenericContextKind ContextKind(NodeFactory factory) { - if (_owningMethodOrType is MethodDesc) + if (_owningMethodOrType is MethodDesc owningMethod) { - MethodDesc owningMethod = (MethodDesc)_owningMethodOrType; Debug.Assert(owningMethod.HasInstantiation); return GenericContextKind.FromMethodHiddenArg | GenericContextKind.NeedsUSGContext; } @@ -800,7 +797,7 @@ public override IEnumerable GetStaticDependencies(NodeFacto { if ((ContextKind(context) & GenericContextKind.HasDeclaringType) != 0) { - return new DependencyListEntry[] + return new DependencyListEntry[] { new DependencyListEntry(context.NativeLayout.TypeSignatureVertex((TypeDesc)_owningMethodOrType), "DeclaringType signature"), new DependencyListEntry(context.GenericDictionaryLayout(_owningMethodOrType), "Dictionary Layout") @@ -849,7 +846,7 @@ public override Vertex WriteVertex(NodeFactory factory) return SetSavedVertex(factory.MetadataManager.NativeLayoutInfo.SignaturesSection.Place(signatureWithContextKind)); } - protected override string GetName(NodeFactory factory) => $"Dictionary layout signature for {_owningMethodOrType.ToString()}"; + protected override string GetName(NodeFactory factory) => $"Dictionary layout signature for {_owningMethodOrType}"; } public sealed class NativeLayoutTemplateMethodLayoutVertexNode : NativeLayoutSavedVertexNode @@ -885,7 +882,7 @@ public override IEnumerable GetStaticDependencies(NodeFacto yield return new DependencyListEntry(context.GenericDictionaryLayout(_method), "Dictionary layout"); } - private int CompareDictionaryEntries(KeyValuePair left, KeyValuePair right) + private static int CompareDictionaryEntries(KeyValuePair left, KeyValuePair right) { return left.Key - right.Key; } @@ -898,7 +895,7 @@ public override Vertex WriteVertex(NodeFactory factory) DictionaryLayoutNode associatedLayout = factory.GenericDictionaryLayout(_method); ICollection templateLayout = associatedLayout.GetTemplateEntries(factory); - + if (!(_method.IsCanonicalMethod(CanonicalFormKind.Universal) || (factory.LazyGenericsPolicy.UsesLazyGenerics(_method))) && (templateLayout.Count > 0)) { List dictionaryVertices = new List(); @@ -1038,7 +1035,7 @@ public override IEnumerable GetStaticDependencies(NodeFacto if (_isUniversalCanon) { - // For universal canonical template types, we need to write out field layout information so that we + // For universal canonical template types, we need to write out field layout information so that we // can correctly compute the type sizes for dynamically created types at runtime, and construct // their GCDesc info foreach (FieldDesc field in _type.GetFields()) @@ -1087,13 +1084,11 @@ public override IEnumerable GetStaticDependencies(NodeFacto if (UniversalGenericParameterLayout.VTableMethodRequiresCallingConventionConverter(implMethod)) { - if (vtableSignatureNodeEntries == null) - vtableSignatureNodeEntries = new List(); + vtableSignatureNodeEntries ??= new List(); vtableSignatureNodeEntries.Add(context.NativeLayout.MethodSignatureVertex(declMethod.GetTypicalMethodDefinition().Signature)); } - } - , _type, _type, _type); + }, _type, _type, _type); if (vtableSignatureNodeEntries != null) { @@ -1124,16 +1119,14 @@ public override IEnumerable GetConditionalStaticDep if (UniversalGenericParameterLayout.VTableMethodRequiresCallingConventionConverter(implMethod)) { - if (conditionalDependencies == null) - conditionalDependencies = new List(); + conditionalDependencies ??= new List(); conditionalDependencies.Add( new CombinedDependencyListEntry(context.NativeLayout.MethodSignatureVertex(declMethod.GetTypicalMethodDefinition().Signature), context.VirtualMethodUse(declMethod), "conditional vtable cctor sig")); } - } - , _type, _type, _type); + }, _type, _type, _type); } if (conditionalDependencies != null) @@ -1142,7 +1135,7 @@ public override IEnumerable GetConditionalStaticDep return Array.Empty(); } - private int CompareDictionaryEntries(KeyValuePair left, KeyValuePair right) + private static int CompareDictionaryEntries(KeyValuePair left, KeyValuePair right) { return left.Key - right.Key; } @@ -1161,7 +1154,7 @@ public override Vertex WriteVertex(NodeFactory factory) DictionaryLayoutNode associatedLayout = factory.GenericDictionaryLayout(_type.ConvertToCanonForm(CanonicalFormKind.Specific).GetClosestDefType()); ICollection templateLayout = associatedLayout.GetTemplateEntries(factory); - + NativeWriter writer = GetNativeWriter(factory); // Interfaces @@ -1202,7 +1195,7 @@ public override Vertex WriteVertex(NodeFactory factory) uint cctorStaticsIndex = factory.MetadataManager.NativeLayoutInfo.StaticsReferences.GetIndex(cctorSymbol); layoutInfo.AppendUnsigned(BagElementKind.ClassConstructorPointer, cctorStaticsIndex); - typeFlags = typeFlags | Internal.NativeFormat.TypeFlags.HasClassConstructor; + typeFlags |= Internal.NativeFormat.TypeFlags.HasClassConstructor; } if (!_isUniversalCanon) @@ -1237,7 +1230,7 @@ public override Vertex WriteVertex(NodeFactory factory) // Determine if type has instantiation determined size if (!_type.IsInterface && HasInstantiationDeterminedSize()) { - typeFlags = typeFlags | Internal.NativeFormat.TypeFlags.HasInstantiationDeterminedSize; + typeFlags |= Internal.NativeFormat.TypeFlags.HasInstantiationDeterminedSize; } } @@ -1290,7 +1283,7 @@ public override Vertex WriteVertex(NodeFactory factory) if (_isUniversalCanon) { - // For universal canonical template types, we need to write out field layout information so that we + // For universal canonical template types, we need to write out field layout information so that we // can correctly compute the type sizes for dynamically created types at runtime, and construct // their GCDesc info VertexSequence fieldsSequence = null; @@ -1302,7 +1295,7 @@ public override Vertex WriteVertex(NodeFactory factory) continue; // NOTE: The order and contents of the signature vertices emitted here is what we consider a field ordinal for the - // purpose of NativeLayoutFieldOffsetGenericDictionarySlotNode. + // purpose of NativeLayoutFieldOffsetGenericDictionarySlotNode. FieldStorage fieldStorage = FieldStorage.Instance; if (field.IsStatic) @@ -1332,8 +1325,7 @@ public override Vertex WriteVertex(NodeFactory factory) Vertex staticFieldVertexData = writer.GetTuple(fieldTypeSignature.WriteVertex(factory), writer.GetUnsignedConstant((uint)fieldStorage)); - if (fieldsSequence == null) - fieldsSequence = new VertexSequence(); + fieldsSequence ??= new VertexSequence(); fieldsSequence.Append(staticFieldVertexData); } @@ -1348,7 +1340,7 @@ public override Vertex WriteVertex(NodeFactory factory) // get invoked. int currentVTableIndexUnused = 0; VertexSequence vtableSignaturesSequence = null; - + ProcessVTableEntriesForCallingConventionSignatureGeneration(factory, VTableEntriesToProcess.AllInVTable, ref currentVTableIndexUnused, (int vtableIndex, bool isSealedVTableSlot, MethodDesc declMethod, MethodDesc implMethod) => { @@ -1357,8 +1349,7 @@ public override Vertex WriteVertex(NodeFactory factory) if (UniversalGenericParameterLayout.VTableMethodRequiresCallingConventionConverter(implMethod)) { - if (vtableSignaturesSequence == null) - vtableSignaturesSequence = new VertexSequence(); + vtableSignaturesSequence ??= new VertexSequence(); NativeLayoutVertexNode methodSignature = factory.NativeLayout.MethodSignatureVertex(declMethod.GetTypicalMethodDefinition().Signature); Vertex signatureVertex = GetNativeWriter(factory).GetRelativeOffsetSignature(methodSignature.WriteVertex(factory)); @@ -1369,8 +1360,7 @@ public override Vertex WriteVertex(NodeFactory factory) vtableSignaturesSequence.Append(vtableSignatureEntry); } - } - , _type, _type, _type); + }, _type, _type, _type); if (vtableSignaturesSequence != null) { @@ -1417,7 +1407,7 @@ private static IEnumerable EnumVirtualSlotsDeclaredOnType(TypeDesc d /// /// Process the vtable entries of a type by calling operation with the vtable index, declaring method, and implementing method - /// Process them in order from 0th entry to last. + /// Process them in order from 0th entry to last. /// Skip generic virtual methods, as they are not present in the vtable itself /// Do not adjust vtable index for generic dictionary slot /// The vtable index is only actually valid if whichEntries is set to VTableEntriesToProcess.AllInVTable @@ -1528,8 +1518,8 @@ public override Vertex WriteVertex(NodeFactory factory) public abstract class NativeLayoutTypeSignatureBasedGenericDictionarySlotNode : NativeLayoutGenericDictionarySlotNode { - NativeLayoutTypeSignatureVertexNode _signature; - TypeDesc _type; + private NativeLayoutTypeSignatureVertexNode _signature; + private TypeDesc _type; public NativeLayoutTypeSignatureBasedGenericDictionarySlotNode(NodeFactory factory, TypeDesc type) { @@ -1658,8 +1648,8 @@ public NativeLayoutAllocateArrayGenericDictionarySlotNode(NodeFactory factory, T public abstract class NativeLayoutStaticsGenericDictionarySlotNode : NativeLayoutGenericDictionarySlotNode { - NativeLayoutTypeSignatureVertexNode _signature; - TypeDesc _type; + private NativeLayoutTypeSignatureVertexNode _signature; + private TypeDesc _type; public NativeLayoutStaticsGenericDictionarySlotNode(NodeFactory factory, TypeDesc type) { @@ -1709,8 +1699,8 @@ public NativeLayoutNonGcStaticsGenericDictionarySlotNode(NodeFactory factory, Ty public sealed class NativeLayoutInterfaceDispatchGenericDictionarySlotNode : NativeLayoutGenericDictionarySlotNode { - NativeLayoutTypeSignatureVertexNode _signature; - MethodDesc _method; + private NativeLayoutTypeSignatureVertexNode _signature; + private MethodDesc _method; public NativeLayoutInterfaceDispatchGenericDictionarySlotNode(NodeFactory factory, MethodDesc method) { @@ -1754,10 +1744,10 @@ protected sealed override Vertex WriteSignatureVertex(NativeWriter writer, NodeF public sealed class NativeLayoutMethodDictionaryGenericDictionarySlotNode : NativeLayoutGenericDictionarySlotNode { - MethodDesc _method; - WrappedMethodDictionaryVertexNode _wrappedNode; + private MethodDesc _method; + private WrappedMethodDictionaryVertexNode _wrappedNode; - private class WrappedMethodDictionaryVertexNode : NativeLayoutMethodEntryVertexNode + private sealed class WrappedMethodDictionaryVertexNode : NativeLayoutMethodEntryVertexNode { public WrappedMethodDictionaryVertexNode(NodeFactory factory, MethodDesc method) : base(factory, method, default(MethodEntryFlags)) @@ -1812,7 +1802,7 @@ protected sealed override Vertex WriteSignatureVertex(NativeWriter writer, NodeF public sealed class NativeLayoutFieldOffsetGenericDictionarySlotNode : NativeLayoutGenericDictionarySlotNode { - FieldDesc _field; + private FieldDesc _field; public NativeLayoutFieldOffsetGenericDictionarySlotNode(FieldDesc field) { @@ -1846,7 +1836,7 @@ protected sealed override Vertex WriteSignatureVertex(NativeWriter writer, NodeF public sealed class NativeLayoutFieldLdTokenGenericDictionarySlotNode : NativeLayoutGenericDictionarySlotNode { - FieldDesc _field; + private FieldDesc _field; public NativeLayoutFieldLdTokenGenericDictionarySlotNode(FieldDesc field) { @@ -1876,8 +1866,8 @@ protected sealed override Vertex WriteSignatureVertex(NativeWriter writer, NodeF public sealed class NativeLayoutVTableOffsetGenericDictionarySlotNode : NativeLayoutGenericDictionarySlotNode { - MethodDesc _method; - MethodDesc _slotDefiningMethod; + private MethodDesc _method; + private MethodDesc _slotDefiningMethod; public NativeLayoutVTableOffsetGenericDictionarySlotNode(MethodDesc method) { @@ -1917,7 +1907,7 @@ protected sealed override Vertex WriteSignatureVertex(NativeWriter writer, NodeF public sealed class NativeLayoutMethodLdTokenGenericDictionarySlotNode : NativeLayoutGenericDictionarySlotNode { - MethodDesc _method; + private MethodDesc _method; public NativeLayoutMethodLdTokenGenericDictionarySlotNode(MethodDesc method) { @@ -1953,8 +1943,8 @@ protected sealed override Vertex WriteSignatureVertex(NativeWriter writer, NodeF public sealed class NativeLayoutCallingConventionConverterGenericDictionarySlotNode : NativeLayoutGenericDictionarySlotNode { - Internal.TypeSystem.MethodSignature _signature; - CallingConventionConverterKind _converterKind; + private Internal.TypeSystem.MethodSignature _signature; + private CallingConventionConverterKind _converterKind; public NativeLayoutCallingConventionConverterGenericDictionarySlotNode(Internal.TypeSystem.MethodSignature signature, CallingConventionConverterKind converterKind) { @@ -1962,7 +1952,7 @@ public NativeLayoutCallingConventionConverterGenericDictionarySlotNode(Internal. _converterKind = converterKind; } - protected sealed override string GetName(NodeFactory factory) => + protected sealed override string GetName(NodeFactory factory) => "NativeLayoutCallingConventionConverterGenericDictionarySlotNode" + _converterKind.ToString() + _signature.GetName(); @@ -1994,9 +1984,9 @@ protected sealed override Vertex WriteSignatureVertex(NativeWriter writer, NodeF public sealed class NativeLayoutConstrainedMethodDictionarySlotNode : NativeLayoutGenericDictionarySlotNode { - MethodDesc _constrainedMethod; - TypeDesc _constraintType; - bool _directCall; + private MethodDesc _constrainedMethod; + private TypeDesc _constraintType; + private bool _directCall; public NativeLayoutConstrainedMethodDictionarySlotNode(MethodDesc constrainedMethod, TypeDesc constraintType, bool directCall) { @@ -2010,7 +2000,7 @@ public NativeLayoutConstrainedMethodDictionarySlotNode(MethodDesc constrainedMet protected sealed override string GetName(NodeFactory factory) => "NativeLayoutConstrainedMethodDictionarySlotNode_" + (_directCall ? "Direct" : "") - + factory.NameMangler.GetMangledMethodName(_constrainedMethod) + + factory.NameMangler.GetMangledMethodName(_constrainedMethod) + "," + factory.NameMangler.GetMangledTypeName(_constraintType); @@ -2092,10 +2082,10 @@ protected sealed override Vertex WriteSignatureVertex(NativeWriter writer, NodeF public sealed class NativeLayoutMethodEntrypointGenericDictionarySlotNode : NativeLayoutGenericDictionarySlotNode { - MethodDesc _method; - WrappedMethodEntryVertexNode _wrappedNode; + private MethodDesc _method; + private WrappedMethodEntryVertexNode _wrappedNode; - private class WrappedMethodEntryVertexNode : NativeLayoutMethodEntryVertexNode + private sealed class WrappedMethodEntryVertexNode : NativeLayoutMethodEntryVertexNode { public bool _unboxingStub; public IMethodNode _functionPointerNode; @@ -2155,7 +2145,7 @@ protected sealed override Vertex WriteSignatureVertex(NativeWriter writer, NodeF public sealed class NativeLayoutIntegerDictionarySlotNode : NativeLayoutGenericDictionarySlotNode { - int _value; + private int _value; public NativeLayoutIntegerDictionarySlotNode(int value) { @@ -2184,7 +2174,7 @@ public override void CheckIfMarkedEnoughToWrite() public sealed class NativeLayoutPointerToOtherSlotDictionarySlotNode : NativeLayoutGenericDictionarySlotNode { - int _otherSlotIndex; + private int _otherSlotIndex; public NativeLayoutPointerToOtherSlotDictionarySlotNode(int otherSlotIndex) { @@ -2221,7 +2211,7 @@ public override IEnumerable GetStaticDependencies(NodeFacto } protected override string GetName(NodeFactory context) => "NativeLayoutNotSupportedDictionarySlotNode"; - + protected override Vertex WriteSignatureVertex(NativeWriter writer, NodeFactory factory) { return writer.GetUnsignedConstant(0xDEADBEEF); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NecessaryCanonicalEETypeNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NecessaryCanonicalEETypeNode.cs index 92cb5e195498c..d7d6671f0df9f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NecessaryCanonicalEETypeNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NecessaryCanonicalEETypeNode.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Diagnostics; using Internal.TypeSystem; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.GenericLookups.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.GenericLookups.cs index 3ab46f5bb0668..3fd5291d643c3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.GenericLookups.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.GenericLookups.cs @@ -8,7 +8,7 @@ namespace ILCompiler.DependencyAnalysis { /// Part of Node factory that deals with nodes describing results of generic lookups. /// See: . - partial class NodeFactory + public partial class NodeFactory { /// /// Helper class that provides a level of grouping for all the generic lookup result kinds. @@ -134,7 +134,7 @@ public GenericLookupResult Type(TypeDesc type) public GenericLookupResult UnwrapNullableType(TypeDesc type) { - // An actual unwrap nullable lookup is only required if the type is exactly a runtime + // An actual unwrap nullable lookup is only required if the type is exactly a runtime // determined type associated with System.__UniversalCanon itself, or if it's // a runtime determined instance of Nullable. if (type.IsRuntimeDeterminedType && ( diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.NativeLayout.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.NativeLayout.cs index b81a81c306405..4d82b88c5d302 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.NativeLayout.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.NativeLayout.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Runtime.CompilerServices; using Internal.Text; using Internal.TypeSystem; @@ -12,14 +11,14 @@ namespace ILCompiler.DependencyAnalysis { /// Part of Node factory that deals with nodes describing native layout information - partial class NodeFactory + public partial class NodeFactory { /// /// Helper class that provides a level of grouping for all the native layout lookups /// public class NativeLayoutHelper { - NodeFactory _factory; + private NodeFactory _factory; public NativeLayoutHelper(NodeFactory factory) { @@ -372,7 +371,7 @@ internal NativeLayoutPlacedVertexSequenceVertexNode PlacedVertexSequence(List> + private sealed class UIntSequenceComparer : IEqualityComparer> { bool IEqualityComparer>.Equals(List x, List y) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs index 9905dcdc255e2..100a736ba501e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs @@ -209,7 +209,7 @@ private void CreateNodeCaches() _GCStaticsPreInitDataNodes = new NodeCache((MetadataType type) => { ISymbolNode gcStaticsNode = TypeGCStaticsSymbol(type); - Debug.Assert(gcStaticsNode is GCStaticsNode); + Debug.Assert(gcStaticsNode is GCStaticsNode); return ((GCStaticsNode)gcStaticsNode).NewPreInitDataNode(); }); @@ -907,8 +907,7 @@ public IMethodNode ShadowConcreteMethod(MethodDesc method, bool isUnboxingStub = public ISymbolNode HelperEntrypoint(HelperEntrypoint entrypoint) { - if (_helperEntrypointSymbols == null) - _helperEntrypointSymbols = new ISymbolNode[s_helperEntrypointNames.Length]; + _helperEntrypointSymbols ??= new ISymbolNode[s_helperEntrypointNames.Length]; int index = (int)entrypoint; @@ -958,12 +957,9 @@ public MethodDesc InstanceMethodRemovedHelper { get { - if (_instanceMethodRemovedHelper == null) - { - // This helper is optional, but it's fine for this cache to be ineffective if that happens. - // Those scenarios are rare and typically deal with small compilations. - _instanceMethodRemovedHelper = TypeSystemContext.GetOptionalHelperEntryPoint("ThrowHelpers", "ThrowInstanceBodyRemoved"); - } + // This helper is optional, but it's fine for this cache to be ineffective if that happens. + // Those scenarios are rare and typically deal with small compilations. + _instanceMethodRemovedHelper ??= TypeSystemContext.GetOptionalHelperEntryPoint("ThrowHelpers", "ThrowInstanceBodyRemoved"); return _instanceMethodRemovedHelper; } @@ -985,21 +981,21 @@ public DependencyNodeCore VariantInterfaceMethodUse(MethodDesc decl private NodeCache _readyToRunHelpers; - public ISymbolNode ReadyToRunHelper(ReadyToRunHelperId id, Object target) + public ISymbolNode ReadyToRunHelper(ReadyToRunHelperId id, object target) { return _readyToRunHelpers.GetOrAdd(new ReadyToRunHelperKey(id, target)); } private NodeCache _genericReadyToRunHelpersFromDict; - public ISymbolNode ReadyToRunHelperFromDictionaryLookup(ReadyToRunHelperId id, Object target, TypeSystemEntity dictionaryOwner) + public ISymbolNode ReadyToRunHelperFromDictionaryLookup(ReadyToRunHelperId id, object target, TypeSystemEntity dictionaryOwner) { return _genericReadyToRunHelpersFromDict.GetOrAdd(new ReadyToRunGenericHelperKey(id, target, dictionaryOwner)); } private NodeCache _genericReadyToRunHelpersFromType; - public ISymbolNode ReadyToRunHelperFromTypeLookup(ReadyToRunHelperId id, Object target, TypeSystemEntity dictionaryOwner) + public ISymbolNode ReadyToRunHelperFromTypeLookup(ReadyToRunHelperId id, object target, TypeSystemEntity dictionaryOwner) { return _genericReadyToRunHelpersFromType.GetOrAdd(new ReadyToRunGenericHelperKey(id, target, dictionaryOwner)); } @@ -1113,7 +1109,7 @@ public string GetSymbolAlternateName(ISymbolNode node) } public ArrayOfEmbeddedPointersNode GCStaticsRegion = new ArrayOfEmbeddedPointersNode( - "__GCStaticRegionStart", + "__GCStaticRegionStart", "__GCStaticRegionEnd", new SortableDependencyNode.ObjectNodeComparer(CompilerComparer.Instance)); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NonGCStaticsNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NonGCStaticsNode.cs index 09ef497952623..99b3e8da8ec16 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NonGCStaticsNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NonGCStaticsNode.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Generic; using Internal.Text; using Internal.TypeSystem; @@ -126,7 +125,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly) { ObjectDataBuilder builder = new ObjectDataBuilder(factory, relocsOnly); - // If the type has a class constructor, its non-GC statics section is prefixed + // If the type has a class constructor, its non-GC statics section is prefixed // by System.Runtime.CompilerServices.StaticClassConstructionContext struct. if (factory.PreinitializationManager.HasLazyStaticConstructor(_type)) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectGetTypeFlowDependenciesNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectGetTypeFlowDependenciesNode.cs index e179848db092d..a30e1a7dc3c55 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectGetTypeFlowDependenciesNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectGetTypeFlowDependenciesNode.cs @@ -8,15 +8,13 @@ using Internal.TypeSystem; -using Debug = System.Diagnostics.Debug; - namespace ILCompiler.DependencyAnalysis { /// /// Represents dataflow dependencies from a call to Object.GetType on an instance statically /// typed as the given type. /// - internal class ObjectGetTypeFlowDependenciesNode : DependencyNodeCore + internal sealed class ObjectGetTypeFlowDependenciesNode : DependencyNodeCore { private readonly MetadataType _type; @@ -33,7 +31,7 @@ protected override string GetName(NodeFactory factory) public override IEnumerable GetStaticDependencies(NodeFactory factory) { var mdManager = (UsageBasedMetadataManager)factory.MetadataManager; - + // We don't mark any members on interfaces - these nodes are only used as conditional dependencies // of other nodes. Calling `object.GetType()` on something typed as an interface will return // something that implements the interface, not the interface itself. We're not reflecting on the @@ -50,6 +48,6 @@ public override IEnumerable GetStaticDependencies(NodeFacto public override bool StaticDependenciesAreComputed => true; public override IEnumerable GetConditionalStaticDependencies(NodeFactory factory) => null; public override IEnumerable SearchDynamicDependencies(List> markedNodes, int firstNode, NodeFactory factory) => null; - + } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs index 5f195f3457473..fb1f38266fbb1 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs @@ -76,7 +76,7 @@ public class ObjectWriter : IDisposable, ITypesDebugInfoWriter private UserDefinedTypeDescriptor _userDefinedTypeDescriptor; #if DEBUG - static Dictionary _previouslyWrittenNodeNames = new Dictionary(); + private static Dictionary _previouslyWrittenNodeNames = new Dictionary(); #endif [DllImport(NativeObjectWriterFileName)] @@ -136,7 +136,7 @@ public enum CustomSectionAttributes /// /// Builds a set of CustomSectionAttributes flags from an ObjectNodeSection. /// - private CustomSectionAttributes GetCustomSectionAttributes(ObjectNodeSection section) + private static CustomSectionAttributes GetCustomSectionAttributes(ObjectNodeSection section) { CustomSectionAttributes attributes = 0; @@ -203,7 +203,7 @@ private int EmitSymbolRef(Utf8StringBuilder symbolName, RelocType relocType, int } [DllImport(NativeObjectWriterFileName)] - private static extern void EmitWinFrameInfo(IntPtr objWriter, byte[] methodName, int startOffset, int endOffset, + private static extern void EmitWinFrameInfo(IntPtr objWriter, byte[] methodName, int startOffset, int endOffset, byte[] blobSymbolName); public void EmitWinFrameInfo(int startOffset, int endOffset, int blobSize, byte[] blobSymbolName) { @@ -342,7 +342,7 @@ public string GetMangledName(TypeDesc type) } [DllImport(NativeObjectWriterFileName)] - private static extern void EmitDebugVar(IntPtr objWriter, string name, UInt32 typeIndex, bool isParam, Int32 rangeCount, ref NativeVarInfo range); + private static extern void EmitDebugVar(IntPtr objWriter, string name, uint typeIndex, bool isParam, int rangeCount, ref NativeVarInfo range); public void EmitDebugVar(INodeWithDebugInfo owningNode, in DebugVarInfoMetadata debugVar) { @@ -398,7 +398,7 @@ public void EmitDebugVarInfo(ObjectNode node) } [DllImport(NativeObjectWriterFileName)] - private static extern void EmitDebugEHClause(IntPtr objWriter, UInt32 TryOffset, UInt32 TryLength, UInt32 HandlerOffset, UInt32 HandlerLength); + private static extern void EmitDebugEHClause(IntPtr objWriter, uint TryOffset, uint TryLength, uint HandlerOffset, uint HandlerLength); public void EmitDebugEHClause(DebugEHClauseInfo ehClause) { @@ -422,7 +422,7 @@ public void EmitDebugEHClauseInfo(ObjectNode node) } [DllImport(NativeObjectWriterFileName)] - private static extern void EmitDebugFunctionInfo(IntPtr objWriter, byte[] methodName, int methodSize, UInt32 methodTypeIndex); + private static extern void EmitDebugFunctionInfo(IntPtr objWriter, byte[] methodName, int methodSize, uint methodTypeIndex); public void EmitDebugFunctionInfo(ObjectNode node, int methodSize) { uint methodTypeIndex = 0; @@ -526,7 +526,7 @@ public void PublishUnwindInfo(ObjectNode node) int end = frameInfo.EndOffset; int len = frameInfo.BlobData.Length; byte[] blob = frameInfo.BlobData; - + _sb.Clear().Append(_nodeFactory.NameMangler.CompilationUnitPrefix).Append("_unwind").Append(i.ToStringInvariant()); byte[] blobSymbolName = _sb.Append(_currentNodeZeroTerminatedName).ToUtf8String().UnderlyingArray; @@ -567,7 +567,7 @@ public void PublishUnwindInfo(ObjectNode node) // For window, just emit the frame blob (UNWIND_INFO) as a whole. EmitWinFrameInfo(start, end, len, blobSymbolName); - + EnsureCurrentSection(); } } @@ -777,7 +777,7 @@ private void AppendExternCPrefix(Utf8StringBuilder sb) { if (_targetPlatform.OperatingSystem == TargetOS.OSX) { - // On OSX, we need to prefix an extra underscore to account for correct linkage of + // On OSX, we need to prefix an extra underscore to account for correct linkage of // extern "C" functions. sb.Append('_'); } @@ -946,7 +946,7 @@ private bool ShouldShareSymbol(ObjectNode node) return true; } - private ObjectNodeSection GetSharedSection(ObjectNodeSection section, string key) + private static ObjectNodeSection GetSharedSection(ObjectNodeSection section, string key) { string standardSectionPrefix = ""; if (section.IsStandardSection) @@ -1017,8 +1017,7 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection instead once it's available to us in this repo @@ -1147,11 +1146,11 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection _id; - public Object Target => _target; + public object Target => _target; public TypeSystemEntity DictionaryOwner => _dictionaryOwner; public GenericLookupResult LookupSignature => _lookupSignature; @@ -258,10 +258,10 @@ public override IEnumerable GetConditionalStaticDep "Type loader template")); } } - + return conditionalDependencies; } - + public override int CompareToImpl(ISortableNode other, CompilerComparer comparer) { var compare = _id.CompareTo(((ReadyToRunGenericHelperNode)other)._id); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReadyToRunHeaderNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReadyToRunHeaderNode.cs index 49f9bafc032c1..243ff6c4769b7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReadyToRunHeaderNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReadyToRunHeaderNode.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using Internal.Runtime; @@ -12,7 +11,7 @@ namespace ILCompiler.DependencyAnalysis { public class ReadyToRunHeaderNode : ObjectNode, ISymbolDefinitionNode { - struct HeaderItem + private struct HeaderItem { public HeaderItem(ReadyToRunSectionType id, ObjectNode node, ISymbolNode startSymbol, ISymbolNode endSymbol) { @@ -22,14 +21,14 @@ public HeaderItem(ReadyToRunSectionType id, ObjectNode node, ISymbolNode startSy EndSymbol = endSymbol; } - readonly public ReadyToRunSectionType Id; - readonly public ObjectNode Node; - readonly public ISymbolNode StartSymbol; - readonly public ISymbolNode EndSymbol; + public readonly ReadyToRunSectionType Id; + public readonly ObjectNode Node; + public readonly ISymbolNode StartSymbol; + public readonly ISymbolNode EndSymbol; } - List _items = new List(); - TargetDetails _target; + private List _items = new List(); + private TargetDetails _target; public ReadyToRunHeaderNode(TargetDetails target) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReadyToRunHelperNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReadyToRunHelperNode.cs index 3787039d53edb..36cc3c5ec1eda 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReadyToRunHelperNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReadyToRunHelperNode.cs @@ -46,9 +46,9 @@ public enum ReadyToRunHelperId public partial class ReadyToRunHelperNode : AssemblyStubNode, INodeWithDebugInfo { private readonly ReadyToRunHelperId _id; - private readonly Object _target; + private readonly object _target; - public ReadyToRunHelperNode(ReadyToRunHelperId id, Object target) + public ReadyToRunHelperNode(ReadyToRunHelperId id, object target) { _id = id; _target = target; @@ -86,7 +86,7 @@ public ReadyToRunHelperNode(ReadyToRunHelperId id, Object target) protected override string GetName(NodeFactory factory) => this.GetMangledName(factory.NameMangler); public ReadyToRunHelperId Id => _id; - public Object Target => _target; + public object Target => _target; public override void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) { @@ -187,8 +187,8 @@ IEnumerable INodeWithDebugInfo.GetNativeSequencePoints() { return new NativeSequencePoint[] { - new NativeSequencePoint(0, String.Empty, WellKnownLineNumber.DebuggerStepThrough), - new NativeSequencePoint(debuggerStepInOffset, String.Empty, WellKnownLineNumber.DebuggerStepIn) + new NativeSequencePoint(0, string.Empty, WellKnownLineNumber.DebuggerStepThrough), + new NativeSequencePoint(debuggerStepInOffset, string.Empty, WellKnownLineNumber.DebuggerStepIn) }; } } @@ -224,7 +224,7 @@ public override int CompareToImpl(ISortableNode other, CompilerComparer comparer default: throw new NotImplementedException(); } - + } #endif } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectableFieldNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectableFieldNode.cs index dd5b429d10438..3fc33b7b03346 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectableFieldNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectableFieldNode.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using ILCompiler.DependencyAnalysisFramework; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectableMethodNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectableMethodNode.cs index 1da18b305c4af..c15760007775d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectableMethodNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectableMethodNode.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using ILCompiler.DependencyAnalysisFramework; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionFieldMapNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionFieldMapNode.cs index 4c88bd1ffa402..f1962ed6b3c0d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionFieldMapNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionFieldMapNode.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Diagnostics; using Internal.Text; using Internal.TypeSystem; @@ -27,7 +26,7 @@ public ReflectionFieldMapNode(ExternalReferencesTableNode externalReferences) } public ISymbolNode EndSymbol => _endSymbol; - + public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) { sb.Append(nameMangler.CompilationUnitPrefix).Append("__field_to_offset_map"); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionInvokeMapNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionInvokeMapNode.cs index f0e9c47b7ea1a..b8ef007f10040 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionInvokeMapNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionInvokeMapNode.cs @@ -51,8 +51,7 @@ public static void AddDependenciesDueToReflectability(ref DependencyList depende { Debug.Assert(factory.MetadataManager.IsReflectionInvokable(method)); - if (dependencies == null) - dependencies = new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(factory.MaximallyConstructableType(method.OwningType), "Reflection invoke"); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionMethodBodyScanner.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionMethodBodyScanner.cs index 6c663d149b328..22ca17d449a23 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionMethodBodyScanner.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionMethodBodyScanner.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.TypeSystem; using AssemblyName = System.Reflection.AssemblyName; @@ -19,8 +17,6 @@ public static bool ResolveType(string name, ModuleDesc callingModule, TypeSystem // not for correctness, so this shortcut is okay. type = null; - referenceModule = null; - int i = 0; // Consume type name part @@ -75,7 +71,7 @@ public static bool ResolveType(string name, ModuleDesc callingModule, TypeSystem referenceModule = callingModule; if (assemblyName.Length > 0) { - referenceModule = context.ResolveAssembly(new AssemblyName(assemblyName.ToString()), false); + referenceModule = context.ResolveAssembly(new AssemblyName(assemblyName.ToString()), false); } if (referenceModule == null) @@ -96,7 +92,7 @@ public static bool ResolveType(string name, ModuleDesc callingModule, TypeSystem } type = mdType; - + return type != null; } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionVirtualInvokeMapNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionVirtualInvokeMapNode.cs index d724d02eda742..dd18d08293d14 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionVirtualInvokeMapNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionVirtualInvokeMapNode.cs @@ -14,7 +14,7 @@ namespace ILCompiler.DependencyAnalysis { /// - /// Represents a map containing the necessary information needed to resolve + /// Represents a map containing the necessary information needed to resolve /// a virtual method target called through reflection. /// internal sealed class ReflectionVirtualInvokeMapNode : ObjectNode, ISymbolDefinitionNode @@ -73,7 +73,7 @@ public static MethodDesc GetDeclaringVirtualMethodAndHierarchyDistance(MethodDes if (containingTypeOfDeclaringMethodForSlot.HasInstantiation) { declaringMethodForSlot = method.Context.GetMethodForInstantiatedType( - declaringMethodForSlot.GetTypicalMethodDefinition(), + declaringMethodForSlot.GetTypicalMethodDefinition(), (InstantiatedType)containingTypeOfDeclaringMethodForSlot); } @@ -86,7 +86,7 @@ public static void GetVirtualInvokeMapDependencies(ref DependencyList dependenci { if (NeedsVirtualInvokeInfo(method)) { - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add( factory.NecessaryTypeSymbol(method.OwningType.ConvertToCanonForm(CanonicalFormKind.Specific)), @@ -143,12 +143,12 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) // // The vtable entries for each instantiated type might not necessarily exist. - // Example 1: + // Example 1: // If there's a call to Foo.Method1 and a call to Foo.Method2, Foo will // not have Method2 in its vtable and Foo will not have Method1. // Example 2: // If there's a call to Foo.Method1 and a call to Foo.Method2, given that both - // of these instantiations share the same canonical form, Foo<__Canon> will have both method + // of these instantiations share the same canonical form, Foo<__Canon> will have both method // entries, and therefore Foo and Foo will have both entries too. // For this reason, the entries that we write to the map in CoreRT will be based on the canonical form // of the method's containing type instead of the open type definition. @@ -165,21 +165,20 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) continue; // Grammar of an entry in the hash table: - // Virtual Method uses a normal slot + // Virtual Method uses a normal slot // TypeKey + NameAndSig metadata offset into the native layout metadata + (NumberOfStepsUpParentHierarchyToType << 1) + slot // OR - // Generic Virtual Method + // Generic Virtual Method // TypeKey + NameAndSig metadata offset into the native layout metadata + (NumberOfStepsUpParentHierarchyToType << 1 + 1) int parentHierarchyDistance; MethodDesc declaringMethodForSlot = GetDeclaringVirtualMethodAndHierarchyDistance(method, out parentHierarchyDistance); - - Vertex vertex = null; - ISymbolNode containingTypeKeyNode = factory.NecessaryTypeSymbol(containingTypeKey); NativeLayoutMethodNameAndSignatureVertexNode nameAndSig = factory.NativeLayout.MethodNameAndSignatureVertex(method.GetTypicalMethodDefinition()); NativeLayoutPlacedSignatureVertexNode placedNameAndSig = factory.NativeLayout.PlacedSignatureVertex(nameAndSig); + + Vertex vertex; if (method.HasInstantiation) { vertex = writer.GetTuple( diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ResourceDataNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ResourceDataNode.cs index 3b2e7577f4aac..99165d639d03a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ResourceDataNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ResourceDataNode.cs @@ -9,7 +9,6 @@ using System.Reflection.PortableExecutable; using Internal.Text; -using Internal.TypeSystem; using Internal.TypeSystem.Ecma; namespace ILCompiler.DependencyAnalysis @@ -19,7 +18,7 @@ namespace ILCompiler.DependencyAnalysis /// Resources are simply copied from the inputs and concatenated into this blob. /// All format information is provided by /// - internal class ResourceDataNode : ObjectNode, ISymbolDefinitionNode + internal sealed class ResourceDataNode : ObjectNode, ISymbolDefinitionNode { /// /// Resource index information generated while extracting resources into the data blob @@ -55,7 +54,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) // This node has no relocations. if (relocsOnly) return new ObjectData(Array.Empty(), Array.Empty(), 1, new ISymbolDefinitionNode[] { this }); - + byte[] blob = GenerateResourceBlob(factory); return new ObjectData( blob, @@ -105,7 +104,7 @@ public IReadOnlyList GetOrCreateIndexData(NodeFactory factory string assemblyName = module.GetName().FullName; BlobReader reader = resourceDirectory.GetReader((int)resource.Offset, resourceDirectory.Length - (int)resource.Offset); int length = (int)reader.ReadUInt32(); - ResourceIndexData indexData = new ResourceIndexData(assemblyName, resourceName, _totalLength, (int)resource.Offset + sizeof(Int32), module, length); + ResourceIndexData indexData = new ResourceIndexData(assemblyName, resourceName, _totalLength, (int)resource.Offset + sizeof(int), module, length); _indexData.Add(indexData); _totalLength += length; } @@ -153,7 +152,7 @@ private byte[] GenerateResourceBlob(NodeFactory factory) /// /// Data about individual manifest resources /// - internal class ResourceIndexData + internal sealed class ResourceIndexData { public ResourceIndexData(string assemblyName, string resourceName, int nativeOffset, int ecmaOffset, EcmaModule ecmaModule, int length) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ResourceIndexNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ResourceIndexNode.cs index e1e7b2d3af90c..ffd0b98be601d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ResourceIndexNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ResourceIndexNode.cs @@ -5,14 +5,13 @@ using Internal.NativeFormat; using Internal.Text; -using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis { /// /// Represents a hash table of resources within the resource blob in the image. /// - internal class ResourceIndexNode : ObjectNode, ISymbolDefinitionNode + internal sealed class ResourceIndexNode : ObjectNode, ISymbolDefinitionNode { private ResourceDataNode _resourceDataNode; @@ -71,7 +70,7 @@ private byte[] GenerateIndexBlob(NodeFactory factory) indexHashtableSection.Place(indexHashtable); // Build a table with a tuple of Assembly Full Name, Resource Name, Offset within the resource data blob, Length - // for each resource. + // for each resource. // This generates a hashtable for the convenience of managed code since there's // a reader for VertexHashtable, but not for VertexSequence. diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/RuntimeFieldHandleNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/RuntimeFieldHandleNode.cs index b681431bcae1b..1f4aae6eaa551 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/RuntimeFieldHandleNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/RuntimeFieldHandleNode.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Diagnostics; using Internal.Text; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/RuntimeMethodHandleNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/RuntimeMethodHandleNode.cs index 5a12f283cd995..673ee8c16813e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/RuntimeMethodHandleNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/RuntimeMethodHandleNode.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Diagnostics; using Internal.Text; @@ -55,7 +54,7 @@ protected override DependencyList ComputeNonRelocationBasedDependencies(NodeFact if (!_targetMethod.IsMethodDefinition && !_targetMethod.OwningType.IsGenericDefinition && _targetMethod.HasInstantiation && _targetMethod.IsVirtual) { - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(factory.GVMDependencies(_targetMethod.GetCanonMethodTarget(CanonicalFormKind.Specific)), "GVM dependencies for runtime method handle"); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ScannedMethodNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ScannedMethodNode.cs index b9d8d941163d0..b4391164b99df 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ScannedMethodNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ScannedMethodNode.cs @@ -65,7 +65,7 @@ public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) { sb.Append(nameMangler.GetMangledMethodName(_method)); } - + public override IEnumerable GetStaticDependencies(NodeFactory factory) { Debug.Assert(_dependencies != null); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/SealedVTableNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/SealedVTableNode.cs index 9330d03e8fe81..bb04c7e0acac5 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/SealedVTableNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/SealedVTableNode.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using ILCompiler.DependencyAnalysisFramework; using Internal.Text; using Internal.TypeSystem; @@ -18,7 +17,7 @@ public class SealedVTableNode : ObjectNode, ISymbolDefinitionNode public SealedVTableNode(TypeDesc type) { - // Multidimensional arrays should not get a sealed vtable or a dispatch map. Runtime should use the + // Multidimensional arrays should not get a sealed vtable or a dispatch map. Runtime should use the // sealed vtable and dispatch map of the System.Array basetype instead. // Pointer arrays also follow the same path Debug.Assert(!type.IsArrayTypeWithoutGenericInterfaces()); @@ -42,7 +41,7 @@ public virtual void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder public override bool StaticDependenciesAreComputed => true; /// - /// Returns the number of sealed vtable slots on the type. This API should only be called after successfully + /// Returns the number of sealed vtable slots on the type. This API should only be called after successfully /// building the sealed vtable slots. /// public int NumSealedVTableEntries @@ -63,7 +62,7 @@ public override bool ShouldSkipEmittingObjectNode(NodeFactory factory) } /// - /// Returns the slot of a method in the sealed vtable, or -1 if not found. This API should only be called after + /// Returns the slot of a method in the sealed vtable, or -1 if not found. This API should only be called after /// successfully building the sealed vtable slots. /// public int ComputeSealedVTableSlot(MethodDesc method) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ShadowConcreteUnboxingThunkNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ShadowConcreteUnboxingThunkNode.cs index 40b7a2f450341..3cc6c0ab95339 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ShadowConcreteUnboxingThunkNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ShadowConcreteUnboxingThunkNode.cs @@ -19,7 +19,7 @@ namespace ILCompiler.DependencyAnalysis /// thunk, as if it was generated. The node acts as a symbol for the canonical thunk /// method for convenience. /// - internal class ShadowConcreteUnboxingThunkNode : DependencyNodeCore, IMethodNode + internal sealed class ShadowConcreteUnboxingThunkNode : DependencyNodeCore, IMethodNode { private IMethodNode _canonicalThunk; @@ -60,7 +60,7 @@ public override IEnumerable GetStaticDependencies(NodeFacto return dependencies; } - protected override string GetName(NodeFactory factory) => $"{Method.ToString()} backed by {_canonicalThunk.GetMangledName(factory.NameMangler)}"; + protected override string GetName(NodeFactory factory) => $"{Method} backed by {_canonicalThunk.GetMangledName(factory.NameMangler)}"; public sealed override bool HasConditionalStaticDependencies => false; public sealed override bool HasDynamicDependencies => false; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StackTraceMethodMappingNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StackTraceMethodMappingNode.cs index 8f3389f584f6a..71be4ee7c4f78 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StackTraceMethodMappingNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StackTraceMethodMappingNode.cs @@ -4,7 +4,6 @@ using System; using Internal.Text; -using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StaticsInfoHashtableNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StaticsInfoHashtableNode.cs index ba32d69a7d8dd..306e5c225c890 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StaticsInfoHashtableNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StaticsInfoHashtableNode.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Diagnostics; using Internal.Text; using Internal.TypeSystem; @@ -38,7 +37,7 @@ public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) public override ObjectNodeSection Section => _externalReferences.Section; public override bool StaticDependenciesAreComputed => true; protected override string GetName(NodeFactory factory) => this.GetMangledName(factory.NameMangler); - + /// /// Helper method to compute the dependencies that would be needed by a hashtable entry for statics info lookup. @@ -60,7 +59,7 @@ public static void AddStaticsInfoDependencies(ref DependencyList dependencies, N if (metadataType.NonGCStaticFieldSize.AsInt > 0 || factory.PreinitializationManager.HasLazyStaticConstructor(type)) { - // The entry in the StaticsInfoHashtable points at the beginning of the static fields data, rather than the cctor + // The entry in the StaticsInfoHashtable points at the beginning of the static fields data, rather than the cctor // context offset. dependencies.Add(factory.TypeNonGCStaticsSymbol(metadataType), "Non-GC statics indirection for StaticsInfoHashtable"); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StringAllocatorMethodNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StringAllocatorMethodNode.cs index 4d45bcf90aada..f5d5be045737f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StringAllocatorMethodNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StringAllocatorMethodNode.cs @@ -19,7 +19,7 @@ namespace ILCompiler.DependencyAnalysis /// This node is used to model the behavior. It represents the symbol for the target allocator /// method and makes sure the String type is marked as constructed. /// - class StringAllocatorMethodNode : DependencyNodeCore, IMethodNode + internal sealed class StringAllocatorMethodNode : DependencyNodeCore, IMethodNode { private readonly MethodDesc _allocationMethod; private readonly MethodDesc _constructorMethod; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMDebug.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMDebug.cs index d32b6a2e8d527..e87f2dc6d353b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMDebug.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMDebug.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using ILCompiler.DependencyAnalysis.ARM; namespace ILCompiler.DependencyAnalysis @@ -15,7 +14,7 @@ public static void EmitNYIAssert(NodeFactory factory, ref ARMEmitter encoder, st [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0) { ISymbolNode NYI_Assert = factory.ExternSymbol("NYI_Assert"); - String CallInfoPrefix = " " + sourceFilePath + "(" + sourceLineNumber.ToString() + "): method " + memberName + ": "; + string CallInfoPrefix = " " + sourceFilePath + "(" + sourceLineNumber.ToString() + "): method " + memberName + ": "; ISymbolNode messageSymbol = factory.ConstantUtf8String(CallInfoPrefix + message); encoder.EmitMOV(encoder.TargetRegister.Arg0, messageSymbol); encoder.EmitJMP(NYI_Assert); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMInitialInterfaceDispatchStubNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMInitialInterfaceDispatchStubNode.cs index 8ba74c2aa06e1..13c7335323480 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMInitialInterfaceDispatchStubNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMInitialInterfaceDispatchStubNode.cs @@ -19,7 +19,7 @@ namespace ILCompiler.DependencyAnalysis /// cell. /// public partial class InitialInterfaceDispatchStubNode : AssemblyStubNode - { + { protected override string GetName(NodeFactory factory) => this.GetMangledName(factory.NameMangler); public override void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMNodeFactory.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMNodeFactory.cs index 3e1bf496dcf37..3bcd30e2ddb40 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMNodeFactory.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMNodeFactory.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - namespace ILCompiler.DependencyAnalysis { public partial class NodeFactory @@ -13,10 +11,7 @@ public InitialInterfaceDispatchStubNode InitialInterfaceDispatchStub { get { - if (_initialInterfaceDispatchStubNode == null) - { - _initialInterfaceDispatchStubNode = new InitialInterfaceDispatchStubNode(); - } + _initialInterfaceDispatchStubNode ??= new InitialInterfaceDispatchStubNode(); return _initialInterfaceDispatchStubNode; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMReadyToRunGenericHelperNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMReadyToRunGenericHelperNode.cs index 2cee3ec3cf97e..aab05e9597e13 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMReadyToRunGenericHelperNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMReadyToRunGenericHelperNode.cs @@ -11,7 +11,7 @@ namespace ILCompiler.DependencyAnalysis { - partial class ReadyToRunGenericHelperNode + public partial class ReadyToRunGenericHelperNode { protected Register GetContextRegister(ref /* readonly */ ARMEmitter encoder) { @@ -214,7 +214,7 @@ protected virtual void EmitLoadGenericContext(NodeFactory factory, ref ARMEmitte } } - partial class ReadyToRunGenericLookupFromTypeNode + public partial class ReadyToRunGenericLookupFromTypeNode { protected override void EmitLoadGenericContext(NodeFactory factory, ref ARMEmitter encoder, bool relocsOnly) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMReadyToRunHelperNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMReadyToRunHelperNode.cs index 44eada8ff9ae6..d2adbfd221742 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMReadyToRunHelperNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMReadyToRunHelperNode.cs @@ -4,8 +4,6 @@ using System; using System.Diagnostics; using Internal.TypeSystem; - -using ILCompiler; using ILCompiler.DependencyAnalysis.ARM; namespace ILCompiler.DependencyAnalysis @@ -13,7 +11,7 @@ namespace ILCompiler.DependencyAnalysis /// /// ARM specific portions of ReadyToRunHelperNode /// - partial class ReadyToRunHelperNode + public partial class ReadyToRunHelperNode { protected override void EmitCode(NodeFactory factory, ref ARMEmitter encoder, bool relocsOnly) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMUnboxingStubNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMUnboxingStubNode.cs index 3968eb92af79b..072121dfc635d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMUnboxingStubNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMUnboxingStubNode.cs @@ -9,7 +9,7 @@ public partial class UnboxingStubNode { protected override void EmitCode(NodeFactory factory, ref ARMEmitter encoder, bool relocsOnly) { - encoder.EmitADD(encoder.TargetRegister.Arg0, (byte)factory.Target.PointerSize); // add r0, sizeof(void*); + encoder.EmitADD(encoder.TargetRegister.Arg0, (byte)factory.Target.PointerSize); // add r0, sizeof(void*); encoder.EmitJMP(GetUnderlyingMethodEntrypoint(factory)); // b methodEntryPoint } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM64/ARM64ReadyToRunGenericHelperNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM64/ARM64ReadyToRunGenericHelperNode.cs index d126ad038c86d..f0e3edc070cc2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM64/ARM64ReadyToRunGenericHelperNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM64/ARM64ReadyToRunGenericHelperNode.cs @@ -11,7 +11,7 @@ namespace ILCompiler.DependencyAnalysis { - partial class ReadyToRunGenericHelperNode + public partial class ReadyToRunGenericHelperNode { protected Register GetContextRegister(ref /* readonly */ ARM64Emitter encoder) { @@ -227,7 +227,7 @@ protected virtual void EmitLoadGenericContext(NodeFactory factory, ref ARM64Emit } } - partial class ReadyToRunGenericLookupFromTypeNode + public partial class ReadyToRunGenericLookupFromTypeNode { protected override void EmitLoadGenericContext(NodeFactory factory, ref ARM64Emitter encoder, bool relocsOnly) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM64/ARM64ReadyToRunHelperNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM64/ARM64ReadyToRunHelperNode.cs index 3360ad8d71d65..8c309fef840fa 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM64/ARM64ReadyToRunHelperNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM64/ARM64ReadyToRunHelperNode.cs @@ -171,7 +171,7 @@ protected override void EmitCode(NodeFactory factory, ref ARM64Emitter encoder, { // Not tested encoder.EmitINT3(); - + encoder.EmitMOV(encoder.TargetRegister.Arg1, factory.InterfaceDispatchCell(targetMethod)); encoder.EmitJMP(factory.ExternSymbol("RhpResolveInterfaceMethod")); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM64/ARM64UnboxingStubNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM64/ARM64UnboxingStubNode.cs index 40596f8338c3d..bfa8aa4512e1e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM64/ARM64UnboxingStubNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM64/ARM64UnboxingStubNode.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using ILCompiler.DependencyAnalysis.ARM64; namespace ILCompiler.DependencyAnalysis @@ -10,7 +9,7 @@ public partial class UnboxingStubNode { protected override void EmitCode(NodeFactory factory, ref ARM64Emitter encoder, bool relocsOnly) { - encoder.EmitADD(encoder.TargetRegister.Arg0, (byte)factory.Target.PointerSize); // add r0, sizeof(void*); + encoder.EmitADD(encoder.TargetRegister.Arg0, (byte)factory.Target.PointerSize); // add r0, sizeof(void*); encoder.EmitJMP(GetUnderlyingMethodEntrypoint(factory)); // b methodEntryPoint } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_LoongArch64/LoongArch64ReadyToRunGenericHelperNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_LoongArch64/LoongArch64ReadyToRunGenericHelperNode.cs index eeb4cfe7c87f3..095056b587f65 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_LoongArch64/LoongArch64ReadyToRunGenericHelperNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_LoongArch64/LoongArch64ReadyToRunGenericHelperNode.cs @@ -11,7 +11,7 @@ namespace ILCompiler.DependencyAnalysis { - partial class ReadyToRunGenericHelperNode + public partial class ReadyToRunGenericHelperNode { protected Register GetContextRegister(ref /* readonly */ LoongArch64Emitter encoder) { @@ -216,7 +216,7 @@ protected virtual void EmitLoadGenericContext(NodeFactory factory, ref LoongArch } } - partial class ReadyToRunGenericLookupFromTypeNode + public partial class ReadyToRunGenericLookupFromTypeNode { protected override void EmitLoadGenericContext(NodeFactory factory, ref LoongArch64Emitter encoder, bool relocsOnly) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_LoongArch64/LoongArch64UnboxingStubNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_LoongArch64/LoongArch64UnboxingStubNode.cs index 7f523d168ff6d..59e7a64abea2d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_LoongArch64/LoongArch64UnboxingStubNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_LoongArch64/LoongArch64UnboxingStubNode.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using ILCompiler.DependencyAnalysis.LoongArch64; namespace ILCompiler.DependencyAnalysis diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_X64/X64ReadyToRunGenericHelperNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_X64/X64ReadyToRunGenericHelperNode.cs index 7f9d0645799f9..802d85ae18c23 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_X64/X64ReadyToRunGenericHelperNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_X64/X64ReadyToRunGenericHelperNode.cs @@ -11,7 +11,7 @@ namespace ILCompiler.DependencyAnalysis { - partial class ReadyToRunGenericHelperNode + public partial class ReadyToRunGenericHelperNode { protected Register GetContextRegister(ref /* readonly */ X64Emitter encoder) { @@ -65,7 +65,7 @@ protected void EmitDictionaryLookup(NodeFactory factory, ref X64Emitter encoder, throw new NotImplementedException(); default: - break; + break; } } @@ -238,7 +238,7 @@ protected virtual void EmitLoadGenericContext(NodeFactory factory, ref X64Emitte } } - partial class ReadyToRunGenericLookupFromTypeNode + public partial class ReadyToRunGenericLookupFromTypeNode { protected override void EmitLoadGenericContext(NodeFactory factory, ref X64Emitter encoder, bool relocsOnly) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_X86/X86ReadyToRunGenericHelperNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_X86/X86ReadyToRunGenericHelperNode.cs index 0367ef8a24a4e..079a38cc7460a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_X86/X86ReadyToRunGenericHelperNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_X86/X86ReadyToRunGenericHelperNode.cs @@ -1,21 +1,15 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using ILCompiler.DependencyAnalysis.X86; -using Internal.TypeSystem; - -using Debug = System.Diagnostics.Debug; - namespace ILCompiler.DependencyAnalysis { - partial class ReadyToRunGenericHelperNode - { + public partial class ReadyToRunGenericHelperNode + { protected sealed override void EmitCode(NodeFactory factory, ref X86Emitter encoder, bool relocsOnly) { - encoder.EmitINT3(); + encoder.EmitINT3(); } - } + } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TentativeInstanceMethodNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TentativeInstanceMethodNode.cs index cf6ff01f4297d..601e594bd69df 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TentativeInstanceMethodNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TentativeInstanceMethodNode.cs @@ -2,11 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; - -using ILCompiler.DependencyAnalysisFramework; - -using Internal.IL; -using Internal.Text; using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TentativeMethodNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TentativeMethodNode.cs index 23d9201244526..55e082c3409de 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TentativeMethodNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TentativeMethodNode.cs @@ -18,7 +18,7 @@ namespace ILCompiler.DependencyAnalysis /// body at object emission phase if the real method body was marked. /// It the real method body wasn't marked, this stub will tail-call into a throw helper. /// - partial class TentativeMethodNode : AssemblyStubNode, IMethodNode, ISymbolNodeWithLinkage + public partial class TentativeMethodNode : AssemblyStubNode, IMethodNode, ISymbolNodeWithLinkage { private readonly IMethodBodyNode _methodNode; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ThreadStaticsNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ThreadStaticsNode.cs index e883af326548e..b1b858022efaa 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ThreadStaticsNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ThreadStaticsNode.cs @@ -39,7 +39,7 @@ public static string GetMangledName(TypeDesc type, NameMangler nameMangler) int ISymbolNode.Offset => 0; int ISymbolDefinitionNode.Offset => OffsetFromBeginningOfArray; - + public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) { sb.Append(GetMangledName(_type, nameMangler)); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TrimmingDescriptorNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TrimmingDescriptorNode.cs index 6fe2a35ff093d..dad7d0a8eceb5 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TrimmingDescriptorNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TrimmingDescriptorNode.cs @@ -1,14 +1,10 @@ //Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using System.IO; -using System.Reflection.Metadata; -using System.Reflection.PortableExecutable; using ILCompiler.DependencyAnalysisFramework; -using Internal.TypeSystem.Ecma; namespace ILCompiler.DependencyAnalysis { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeGVMEntriesNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeGVMEntriesNode.cs index 12472274c917a..e13fa43f59c89 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeGVMEntriesNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeGVMEntriesNode.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using System.Diagnostics; @@ -27,7 +26,7 @@ public TypeGVMEntryInfo(MethodDesc callingMethod, MethodDesc implementationMetho public MethodDesc ImplementationMethod { get; } } - internal class InterfaceGVMEntryInfo : TypeGVMEntryInfo + internal sealed class InterfaceGVMEntryInfo : TypeGVMEntryInfo { public InterfaceGVMEntryInfo(MethodDesc callingMethod, MethodDesc implementationMethod, TypeDesc implementationType, DefaultInterfaceMethodResolution defaultResolution) @@ -40,7 +39,7 @@ public InterfaceGVMEntryInfo(MethodDesc callingMethod, MethodDesc implementation public TypeDesc ImplementationType { get; } public DefaultInterfaceMethodResolution DefaultResolution { get; } } - + private readonly TypeDesc _associatedType; private DependencyList _staticDependencies; @@ -89,7 +88,7 @@ public static bool TypeNeedsGVMTableEntries(TypeDesc type) return true; // - // Check if the type implements any interface with GVM methods, where the method implementations could be on + // Check if the type implements any interface with GVM methods, where the method implementations could be on // base types. // Example: // interface IFace { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeManagerIndirectionNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeManagerIndirectionNode.cs index 8e737fde4fb91..9d1c3c37df35e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeManagerIndirectionNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeManagerIndirectionNode.cs @@ -1,10 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.Text; -using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeMetadataMapNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeMetadataMapNode.cs index ab69129df3f27..f0132ece3afa7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeMetadataMapNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeMetadataMapNode.cs @@ -5,7 +5,6 @@ using Internal.NativeFormat; using Internal.Text; -using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis { @@ -56,7 +55,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) // not unifying to the same System.Type at runtime. if (!factory.MetadataManager.TypeGeneratesEEType(mappingEntry.Entity) && !factory.CompilationModuleGroup.ShouldReferenceThroughImportTable(mappingEntry.Entity)) continue; - + // Go with a necessary type symbol. It will be upgraded to a constructed one if a constructed was emitted. IEETypeNode typeSymbol = factory.NecessaryTypeSymbol(mappingEntry.Entity); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeMetadataNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeMetadataNode.cs index 12b9913fabe97..db8c11315b4b9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeMetadataNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeMetadataNode.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using ILCompiler.DependencyAnalysisFramework; @@ -19,7 +18,7 @@ namespace ILCompiler.DependencyAnalysis /// /// Only expected to be used during ILScanning when scanning for reflection. /// - internal class TypeMetadataNode : DependencyNodeCore + internal sealed class TypeMetadataNode : DependencyNodeCore { private readonly MetadataType _type; @@ -129,7 +128,7 @@ public static void GetMetadataDependencies(ref DependencyList dependencies, Node { if (mdManager.CanGenerateMetadata((MetadataType)typeDefinition)) { - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(nodeFactory.TypeMetadata((MetadataType)typeDefinition), reason); } @@ -142,7 +141,7 @@ public static void GetMetadataDependencies(ref DependencyList dependencies, Node { if (mdManager.CanGenerateMetadata((MetadataType)type)) { - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(nodeFactory.TypeMetadata((MetadataType)type), reason); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/UnboxingStubNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/UnboxingStubNode.cs index 29f9222b3011b..5bad84e227d3e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/UnboxingStubNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/UnboxingStubNode.cs @@ -1,13 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.Text; using Internal.TypeSystem; -using ILCompiler.DependencyAnalysisFramework; - using Debug = System.Diagnostics.Debug; namespace ILCompiler.DependencyAnalysis @@ -20,8 +16,8 @@ public partial class UnboxingStubNode : AssemblyStubNode, IMethodNode, ISymbolDe // Section name on Windows has to be alphabetically less than the ending WindowsUnboxingStubsRegionNode node, and larger than // the begining WindowsUnboxingStubsRegionNode node, in order to have proper delimiters to the begining/ending of the // stubs region, in order for the runtime to know where the region starts and ends. - internal static readonly string WindowsSectionName = ".unbox$M"; - internal static readonly string UnixSectionName = "__unbox"; + internal const string WindowsSectionName = ".unbox$M"; + internal const string UnixSectionName = "__unbox"; private readonly TargetDetails _targetDetails; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VTableSliceNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VTableSliceNode.cs index 8d80ea2f684e3..02975e52407d6 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VTableSliceNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VTableSliceNode.cs @@ -11,7 +11,7 @@ namespace ILCompiler.DependencyAnalysis { /// - /// Represents the VTable for a type's slice. For example, System.String's VTableSliceNode includes virtual + /// Represents the VTable for a type's slice. For example, System.String's VTableSliceNode includes virtual /// slots added by System.String itself, System.Object's VTableSliceNode contains the virtuals it defines. /// public abstract class VTableSliceNode : DependencyNodeCore @@ -39,7 +39,7 @@ public abstract bool HasFixedSlots get; } - protected override string GetName(NodeFactory factory) => $"__vtable_{factory.NameMangler.GetMangledTypeName(_type).ToString()}"; + protected override string GetName(NodeFactory factory) => $"__vtable_{factory.NameMangler.GetMangledTypeName(_type)}"; public override bool StaticDependenciesAreComputed => true; @@ -104,7 +104,7 @@ public EagerlyBuiltVTableSliceNode(TypeDesc type) private static IReadOnlyList ComputeSlots(TypeDesc type) { - var slots = new ArrayBuilder(); + var slots = default(ArrayBuilder); bool isObjectType = type.IsObject; DefType defType = type.GetClosestDefType(); @@ -157,7 +157,7 @@ public override IReadOnlyList Slots // in GetAllMethods()). // This ensures that Foo and Foo will end up with the same vtable // no matter the order in which VirtualMethodUse nodes populated it. - ArrayBuilder slotsBuilder = new ArrayBuilder(); + ArrayBuilder slotsBuilder = default(ArrayBuilder); DefType defType = _type.GetClosestDefType(); foreach (var method in defType.GetAllMethods()) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VariantInterfaceMethodUseNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VariantInterfaceMethodUseNode.cs index 06135a1dfca12..a81bffeb0b785 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VariantInterfaceMethodUseNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VariantInterfaceMethodUseNode.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using ILCompiler.DependencyAnalysisFramework; @@ -20,7 +19,7 @@ namespace ILCompiler.DependencyAnalysis // There's a potential optimization opportunity because e.g. the fact that // IEnumerable.GetEnumerator() is used doesn't mean that // IEnumerable.GetEnumerator() is used, but this complicates the tracking. - internal class VariantInterfaceMethodUseNode : DependencyNodeCore + internal sealed class VariantInterfaceMethodUseNode : DependencyNodeCore { private readonly MethodDesc _decl; @@ -141,7 +140,7 @@ public static bool IsVariantMethodCall(NodeFactory factory, MethodDesc calledMet return result; } - protected override string GetName(NodeFactory factory) => $"VariantInterfaceMethodUse {_decl.ToString()}"; + protected override string GetName(NodeFactory factory) => $"VariantInterfaceMethodUse {_decl}"; public override bool HasConditionalStaticDependencies => false; public override bool HasDynamicDependencies => false; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VirtualMethodUseNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VirtualMethodUseNode.cs index b9f9e63a7d4be..f97208602afdd 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VirtualMethodUseNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VirtualMethodUseNode.cs @@ -18,7 +18,7 @@ namespace ILCompiler.DependencyAnalysis // // It is used to keep track of uses of virtual methods to ensure that the // vtables are properly constructed - internal class VirtualMethodUseNode : DependencyNodeCore + internal sealed class VirtualMethodUseNode : DependencyNodeCore { private readonly MethodDesc _decl; @@ -38,15 +38,14 @@ public VirtualMethodUseNode(MethodDesc decl) _decl = decl; } - protected override string GetName(NodeFactory factory) => $"VirtualMethodUse {_decl.ToString()}"; + protected override string GetName(NodeFactory factory) => $"VirtualMethodUse {_decl}"; protected override void OnMarked(NodeFactory factory) { // If the VTable slice is getting built on demand, the fact that the virtual method is used means // that the slot is used. var lazyVTableSlice = factory.VTable(_decl.OwningType) as LazilyBuiltVTableSliceNode; - if (lazyVTableSlice != null) - lazyVTableSlice.AddEntry(factory, _decl); + lazyVTableSlice?.AddEntry(factory, _decl); } public override bool HasConditionalStaticDependencies => _decl.Context.SupportsUniversalCanon && _decl.OwningType.HasInstantiation && !_decl.OwningType.IsInterface; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DescriptorMarker.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DescriptorMarker.cs index 1de3b33c13770..1552bbf956e9d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DescriptorMarker.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DescriptorMarker.cs @@ -8,13 +8,9 @@ using System.IO; using System.Linq; using System.Reflection.Metadata; -using System.Text; using System.Xml.XPath; - -using ILCompiler; using ILCompiler.Dataflow; using ILCompiler.DependencyAnalysis; -using ILLink.Shared; using Internal.TypeSystem; using DependencyList = ILCompiler.DependencyAnalysisFramework.DependencyNodeCore.DependencyList; @@ -25,14 +21,12 @@ namespace ILCompiler { internal sealed class DescriptorMarker : ProcessLinkerXmlBase { - const string NamespaceElementName = "namespace"; - - const string _required = "required"; - const string _preserve = "preserve"; - const string _accessors = "accessors"; - - static readonly string[] _accessorsAll = new string[] { "all" }; - static readonly char[] _accessorsSep = new char[] { ';' }; + private const string NamespaceElementName = "namespace"; + private const string _required = "required"; + private const string _preserve = "preserve"; + private const string _accessors = "accessors"; + private static readonly string[] _accessorsAll = new string[] { "all" }; + private static readonly char[] _accessorsSep = new char[] { ';' }; private NodeFactory _factory; @@ -60,7 +54,7 @@ protected override void ProcessAssembly(ModuleDesc assembly, XPathNavigator nav, { foreach (var type in assembly.GetAllTypes()) MarkAndPreserve(type, nav, TypePreserve.All); - + //foreach (var exportedType in assembly.MainModule.ExportedTypes) // _context.MarkingHelpers.MarkExportedType(exportedType, assembly.MainModule, new DependencyInfo(DependencyKind.XmlDescriptor, assembly.MainModule), GetMessageOriginForPosition(nav)); } @@ -71,7 +65,7 @@ protected override void ProcessAssembly(ModuleDesc assembly, XPathNavigator nav, } } - void ProcessNamespaces(ModuleDesc assembly, XPathNavigator nav) + private void ProcessNamespaces(ModuleDesc assembly, XPathNavigator nav) { foreach (XPathNavigator namespaceNav in nav.SelectChildren(NamespaceElementName, XmlNamespace)) { @@ -96,7 +90,7 @@ void ProcessNamespaces(ModuleDesc assembly, XPathNavigator nav) } } - void MarkAndPreserve(TypeDesc type, XPathNavigator nav, TypePreserve preserve) + private void MarkAndPreserve(TypeDesc type, XPathNavigator nav, TypePreserve preserve) { var bindingOptions = preserve switch { TypePreserve.Methods => DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods, @@ -200,7 +194,7 @@ protected override void ProcessType(TypeDesc type, XPathNavigator nav) #endif } - static TypePreserve GetTypePreserve(XPathNavigator nav) + private static TypePreserve GetTypePreserve(XPathNavigator nav) { string attribute = GetAttribute(nav, _preserve); if (string.IsNullOrEmpty(attribute)) @@ -242,7 +236,7 @@ protected override void ProcessMethod(TypeDesc type, MethodDesc method, XPathNav } } - void ProcessMethodIfNotNull(TypeDesc type, MethodDesc method, XPathNavigator nav, object? customData) + private void ProcessMethodIfNotNull(TypeDesc type, MethodDesc method, XPathNavigator nav, object? customData) { if (method == null) return; @@ -254,7 +248,7 @@ void ProcessMethodIfNotNull(TypeDesc type, MethodDesc method, XPathNavigator nav { foreach (MethodDesc meth in type.GetAllMethods()) { - if (signature == ProcessLinkerXmlBase.GetMethodSignature(meth, false)) + if (signature == GetMethodSignature(meth, false)) return meth; } return null; @@ -303,7 +297,7 @@ protected override void ProcessProperty(TypeDesc type, PropertyPseudoDesc proper } } - static bool IsRequired(XPathNavigator nav) + private static bool IsRequired(XPathNavigator nav) { string attribute = GetAttribute(nav, _required); if (attribute == null || attribute.Length == 0) @@ -312,7 +306,7 @@ static bool IsRequired(XPathNavigator nav) return bool.TryParse(attribute, out bool result) && result; } - static string[] GetAccessors(XPathNavigator nav) + private static string[] GetAccessors(XPathNavigator nav) { string accessorsValue = GetAttribute(nav, _accessors); @@ -324,7 +318,7 @@ static string[] GetAccessors(XPathNavigator nav) if (accessors.Length > 0) { for (int i = 0; i < accessors.Length; ++i) - accessors[i] = accessors[i].ToLower(); + accessors[i] = accessors[i].ToLowerInvariant(); return accessors; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Disassembler.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Disassembler.cs index fc45079be5f19..e44fa04665bf0 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Disassembler.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Disassembler.cs @@ -64,7 +64,7 @@ public static string Disassemble(TargetArchitecture arch, byte[] bytes, Relocati return sb.ToString(); } - private class CoreDisassembler : IDisposable + private sealed class CoreDisassembler : IDisposable { private IntPtr _handle; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/EmptyInteropStubManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/EmptyInteropStubManager.cs index fa7a13b217d15..53dc3e7143a53 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/EmptyInteropStubManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/EmptyInteropStubManager.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.TypeSystem; using ILCompiler.DependencyAnalysis; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/FeatureSettings.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/FeatureSettings.cs index 773c061081e45..29781b6448ed9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/FeatureSettings.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/FeatureSettings.cs @@ -1,11 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using System.Xml.XPath; -using ILLink.Shared; -using Internal.TypeSystem; namespace ILCompiler { @@ -46,7 +43,7 @@ public static bool ShouldProcessElement(XPathNavigator nav, IReadOnlyDictionary< public static string GetAttribute(XPathNavigator nav, string attribute) { - return nav.GetAttribute(attribute, String.Empty); + return nav.GetAttribute(attribute, string.Empty); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/FeatureSwitchManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/FeatureSwitchManager.cs index 9bc4741771bcf..781c1f455940c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/FeatureSwitchManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/FeatureSwitchManager.cs @@ -3,14 +3,11 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.IO; using System.Reflection.Metadata; using System.Reflection.PortableExecutable; -using System.Xml; using Internal.IL; -using Internal.IL.Stubs; using Internal.TypeSystem; using Internal.TypeSystem.Ecma; @@ -102,7 +99,7 @@ public override MethodIL GetMethodIL(MethodDesc method) // Flags that we track for each byte of the IL instruction stream. [Flags] - enum OpcodeFlags : byte + private enum OpcodeFlags : byte { // This offset is an instruction boundary. InstructionStart = 0x1, @@ -447,7 +444,7 @@ public MethodIL GetMethodILWithInlinedSubstitutions(MethodIL method) // EH regions with unmarked handlers belong to unmarked basic blocks // Need to eliminate them because they're not usable. - ArrayBuilder newEHRegions = new ArrayBuilder(); + ArrayBuilder newEHRegions = default(ArrayBuilder); foreach (ILExceptionRegion ehRegion in ehRegions) { if ((flags[ehRegion.HandlerOffset] & OpcodeFlags.Mark) != 0) @@ -463,7 +460,7 @@ public MethodIL GetMethodILWithInlinedSubstitutions(MethodIL method) IEnumerable oldSequencePoints = debugInfo?.GetSequencePoints(); if (oldSequencePoints != null) { - ArrayBuilder sequencePoints = new ArrayBuilder(); + ArrayBuilder sequencePoints = default(ArrayBuilder); foreach (var sequencePoint in oldSequencePoints) { if (sequencePoint.Offset < flags.Length && (flags[sequencePoint.Offset] & OpcodeFlags.Mark) != 0) @@ -644,7 +641,7 @@ private bool TryGetConstantArgument(MethodIL methodIL, byte[] body, OpcodeFlags[ return false; } - private class SubstitutedMethodIL : MethodIL + private sealed class SubstitutedMethodIL : MethodIL { private readonly byte[] _body; private readonly ILExceptionRegion[] _ehRegions; @@ -669,7 +666,7 @@ public SubstitutedMethodIL(MethodIL wrapped, byte[] body, ILExceptionRegion[] eh public override MethodDebugInformation GetDebugInfo() => _debugInfo; } - private class SubstitutedDebugInformation : MethodDebugInformation + private sealed class SubstitutedDebugInformation : MethodDebugInformation { private readonly MethodDebugInformation _originalDebugInformation; private readonly ILSequencePoint[] _sequencePoints; @@ -685,7 +682,7 @@ public SubstitutedDebugInformation(MethodDebugInformation originalDebugInformati public override IEnumerable GetSequencePoints() => _sequencePoints; } - private class FeatureSwitchHashtable : LockFreeReaderHashtable + private sealed class FeatureSwitchHashtable : LockFreeReaderHashtable { private readonly Dictionary _switchValues; @@ -705,7 +702,7 @@ protected override AssemblyFeatureInfo CreateValueFromKey(EcmaModule key) } } - private class AssemblyFeatureInfo + private sealed class AssemblyFeatureInfo { public EcmaModule Module { get; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/GeneratingMetadataManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/GeneratingMetadataManager.cs index eff63e3867837..3a462b4c9ee81 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/GeneratingMetadataManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/GeneratingMetadataManager.cs @@ -5,17 +5,12 @@ using System.IO; using System.Collections.Generic; using System.Text; - -using Internal.IL; -using Internal.IL.Stubs; using Internal.TypeSystem; using Internal.Metadata.NativeFormat.Writer; using ILCompiler.Metadata; using ILCompiler.DependencyAnalysis; -using DependencyList = ILCompiler.DependencyAnalysisFramework.DependencyNodeCore.DependencyList; - namespace ILCompiler { /// @@ -130,8 +125,7 @@ protected void ComputeMetadata( // Reflection requires that we maintain type identity. Even if we only generated a TypeReference record, // if there is an MethodTable for it, we also need a mapping table entry for it. - if (record == null) - record = transformed.GetTransformedTypeReference(definition); + record ??= transformed.GetTransformedTypeReference(definition); if (record != null) typeMappings.Add(new MetadataMapping(definition, writer.GetRecordHandle(record))); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/GenericDictionaryLookup.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/GenericDictionaryLookup.cs index 49005719c94cd..a6e088fab7045 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/GenericDictionaryLookup.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/GenericDictionaryLookup.cs @@ -56,7 +56,7 @@ public ReadyToRunHelperId HelperId } /// - /// Gets a value indicating whether the lookup needs to be performed by calling a helper method. + /// Gets a value indicating whether the lookup needs to be performed by calling a helper method. /// public bool UseHelper { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/GenericRootProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/GenericRootProvider.cs index 22a2029b3a189..acbc3a1d16967 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/GenericRootProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/GenericRootProvider.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Internal.TypeSystem.Ecma; -using Internal.TypeSystem; using System; namespace ILCompiler diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILAssemblyGeneratingMethodDebugInfoProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILAssemblyGeneratingMethodDebugInfoProvider.cs index 91ef798d5b26d..1732ce8995652 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILAssemblyGeneratingMethodDebugInfoProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILAssemblyGeneratingMethodDebugInfoProvider.cs @@ -61,7 +61,7 @@ private MethodDebugInformation GetDebugInformation(MethodIL methodIL) var disasm = new ILDisassembler(methodIL); var fmt = new ILDisassembler.ILTypeNameFormatter(null); - ArrayBuilder sequencePoints = new ArrayBuilder(); + ArrayBuilder sequencePoints = default(ArrayBuilder); _tw.Write(".method "); // TODO: accessibility, specialname, calling conventions etc. @@ -146,7 +146,7 @@ public void Dispose() _tw.Dispose(); } - private class SyntheticMethodDebugInformation : MethodDebugInformation + private sealed class SyntheticMethodDebugInformation : MethodDebugInformation { private readonly ILSequencePoint[] _sequencePoints; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs index 7c6d2ab6431d6..ab6c2b0b99d32 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs @@ -149,7 +149,7 @@ public ISymbolNode GetHelperEntrypoint(ReadyToRunHelper helper) return _helperCache.GetOrCreateValue(helper).Symbol; } - class Helper + private sealed class Helper { public ReadyToRunHelper HelperID { get; } public ISymbolNode Symbol { get; } @@ -162,7 +162,8 @@ public Helper(ReadyToRunHelper id, ISymbolNode symbol) } private HelperCache _helperCache; - class HelperCache : LockFreeReaderHashtable + + private sealed class HelperCache : LockFreeReaderHashtable { private Compilation _compilation; @@ -199,7 +200,7 @@ public interface IILScanner ILScanResults Scan(); } - internal class ScannerFailedException : InternalCompilerErrorException + internal sealed class ScannerFailedException : InternalCompilerErrorException { public ScannerFailedException(string message) : base(message + " " + "You can work around by running the compilation with scanner disabled.") @@ -246,7 +247,7 @@ public MethodImportationErrorProvider GetMethodImportationErrorProvider() return new ScannedMethodImportationErrorProvider(MarkedNodes); } - private class ScannedVTableProvider : VTableSliceProvider + private sealed class ScannedVTableProvider : VTableSliceProvider { private Dictionary> _vtableSlices = new Dictionary>(); @@ -288,7 +289,7 @@ internal override VTableSliceNode GetSlice(TypeDesc type) } } - private class ScannedDictionaryLayoutProvider : DictionaryLayoutProvider + private sealed class ScannedDictionaryLayoutProvider : DictionaryLayoutProvider { private Dictionary> _layouts = new Dictionary>(); private HashSet _entitiesWithForcedLazyLookups = new HashSet(); @@ -362,7 +363,7 @@ public override DictionaryLayoutNode GetLayout(TypeSystemEntity methodOrType) } } - private class ScannedDevirtualizationManager : DevirtualizationManager + private sealed class ScannedDevirtualizationManager : DevirtualizationManager { private HashSet _constructedTypes = new HashSet(); private HashSet _canonConstructedTypes = new HashSet(); @@ -571,7 +572,7 @@ public override TypeDesc[] GetImplementingClasses(TypeDesc type) } } - private class ScannedInliningPolicy : IInliningPolicy + private sealed class ScannedInliningPolicy : IInliningPolicy { private readonly HashSet _constructedTypes = new HashSet(); private readonly CompilationModuleGroup _baseGroup; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScannerBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScannerBuilder.cs index 7eeabcb00ac4a..887c90703daf7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScannerBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScannerBuilder.cs @@ -6,8 +6,6 @@ using ILCompiler.DependencyAnalysis; using ILCompiler.DependencyAnalysisFramework; - -using Internal.TypeSystem; using Internal.IL; namespace ILCompiler diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILStreamReader.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILStreamReader.cs index 1f1310d3d0653..8238d72a3f8a3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILStreamReader.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILStreamReader.cs @@ -11,7 +11,7 @@ namespace Internal.Compiler /// /// IL Opcode reader in external reader style where the reading is done by trying to read /// various opcodes, and the reader can indicate success or failure of reading a particular opcode - /// + /// /// Used by logic which is designed to encode information in il structure, but not used /// to support general compilation of IL. /// diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILogWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILogWriter.cs index 400c87ef8853b..8ac77016e1389 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILogWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILogWriter.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.IO; using ILCompiler.Logging; namespace ILCompiler diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/InteropStubManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/InteropStubManager.cs index 3c5c4b9d13339..3ea2357cda46c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/InteropStubManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/InteropStubManager.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.IL; using Internal.TypeSystem; using ILCompiler.DependencyAnalysis; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs index 3cbd44db0b389..ceeffa099ce4b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs @@ -9,7 +9,7 @@ namespace ILCompiler { - internal class JitHelper + internal static class JitHelper { /// /// Returns JIT helper entrypoint. JIT helpers can be either implemented by entrypoint with given mangled name or diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/Graph.Cycles.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/Graph.Cycles.cs index 9819cd855c5e7..718609d93fe1f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/Graph.Cycles.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/Graph.Cycles.cs @@ -14,12 +14,12 @@ internal static partial class LazyGenericsSupport private sealed partial class Graph

{ - class TarjanWorkerClass + private sealed class TarjanWorkerClass { - Stack _inProgress = new Stack(); - int _currentComponentIndex = 0; - Vertex[] _vertices; - List> _result = new List>(); + private Stack _inProgress = new Stack(); + private int _currentComponentIndex; + private Vertex[] _vertices; + private List> _result = new List>(); public TarjanWorkerClass(Vertex[] vertices, bool iterative) { @@ -48,7 +48,7 @@ public TarjanWorkerClass(Vertex[] vertices, bool iterative) } } - void StrongConnectRecursive(Vertex vertex) + private void StrongConnectRecursive(Vertex vertex) { vertex.Index = _currentComponentIndex; vertex.LowLink = _currentComponentIndex; @@ -89,7 +89,7 @@ void StrongConnectRecursive(Vertex vertex) } } - struct StrongConnectStackElement + private struct StrongConnectStackElement { public Vertex Vertex; public IEnumerator EdgeEnumeratorPosition; @@ -97,11 +97,13 @@ struct StrongConnectStackElement private Stack IterativeStrongConnectStack = new Stack(); - void StrongConnectIterative(Vertex vertex) + private void StrongConnectIterative(Vertex vertex) { +#pragma warning disable IDE0059 // Unnecessary assignment of a value IEnumerator currentEdgeEnumerator = null; +#pragma warning restore IDE0059 // Unnecessary assignment of a value -StartOfFunctionWithLogicalRecursion: + StartOfFunctionWithLogicalRecursion: vertex.Index = _currentComponentIndex; vertex.LowLink = _currentComponentIndex; @@ -130,13 +132,15 @@ void StrongConnectIterative(Vertex vertex) if (edge.Destination.Index == -1) { // Recurse if the destination has not begun processing yet - StrongConnectStackElement iterativeStackElement = new StrongConnectStackElement(); + StrongConnectStackElement iterativeStackElement = default(StrongConnectStackElement); iterativeStackElement.Vertex = vertex; iterativeStackElement.EdgeEnumeratorPosition = currentEdgeEnumerator; IterativeStrongConnectStack.Push(iterativeStackElement); +#pragma warning disable IDE0059 // Unnecessary assignment of a value currentEdgeEnumerator = null; +#pragma warning restore IDE0059 // Unnecessary assignment of a value vertex = edge.Destination; goto StartOfFunctionWithLogicalRecursion; } @@ -204,7 +208,7 @@ public IEnumerable

ComputeVerticesInvolvedInAFlaggedCycle() foreach (List stronglyConnectedComponent in stronglyConnectedComponents) { HashSet strongConnectedComponentVertexContainsChecker = new HashSet(stronglyConnectedComponent); - // Detect flags between elements of cycle. + // Detect flags between elements of cycle. // Walk all edges of the strongly connected component. // - If an edge is not flagged, it can't affect behavior // - If an edge is flagged, if it refers to another Vertex in the strongly connected component, then the cycle should be flagged. @@ -335,7 +339,7 @@ private void FindCyclesWorker(Edge edge, List alreadySeen, ref int operati // If this a vertex we've visited already on this path? bool flagged = edge.Flagged || vertex.ProvedToBeInvolvedInAFlaggedCycle; - + int idx = alreadySeen.Count - 1; while (idx != -1 && !(alreadySeen[idx].Destination == vertex)) { @@ -348,10 +352,10 @@ private void FindCyclesWorker(Edge edge, List alreadySeen, ref int operati { Debug.Assert(alreadySeen[idx].Destination == vertex); - // We've seen this vertex already in our path. We now know that this vertex is involved in a simple cycle. + // We've seen this vertex already in our path. We now know that this vertex is involved in a simple cycle. // - // At minimum, we need to mark the root vertex (alreadySeen[0].Destination) if the cycle includes the root and - // includes a flagged edge or a vertex that is itself known to be part of a flagged cycle. + // At minimum, we need to mark the root vertex (alreadySeen[0].Destination) if the cycle includes the root and + // includes a flagged edge or a vertex that is itself known to be part of a flagged cycle. // That's the primary answer our caller seeks. // // At minimum, we also need to stop recursing so that our caller gets an answer at all. @@ -387,4 +391,3 @@ private void FindCyclesWorker(Edge edge, List alreadySeen, ref int operati } } } - diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/Graph.Vertex.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/Graph.Vertex.cs index 1aaeaa191b663..709113b27b392 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/Graph.Vertex.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/Graph.Vertex.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; namespace ILCompiler @@ -75,7 +74,7 @@ public void AddEdge(Vertex toVertex, bool flagged) ///

/// Flag used during Tarjan's algorithm /// - public bool OnStack = false; + public bool OnStack; /// /// Index used in Tarjan's algorithm @@ -87,7 +86,7 @@ public void AddEdge(Vertex toVertex, bool flagged) /// public int LowLink = -1; - public sealed override String ToString() + public sealed override string ToString() { return this.Payload.ToString(); } @@ -107,14 +106,13 @@ public Edge(Vertex destination, bool flagged) public readonly Vertex Destination; public bool Flagged; - public override String ToString() + public override string ToString() { return "[" + (Flagged ? "==>" : "-->") + Destination + "]"; } } - + private Dictionary _vertexMap = new Dictionary(); } } } - diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/Graph.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/Graph.cs index 12fcc14766cd4..4bb4ff814c660 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/Graph.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/Graph.cs @@ -10,7 +10,7 @@ internal static partial class LazyGenericsSupport { /// /// A weighted directed graph abstraction. For our purposes, we only use two weights, so our "weight" is a boolean: "Flagged" or "Not Flagged". - /// + /// /// The generic type "P" denotes the type that holds the payload data of graph vertices. Its overload of Object.Equals() is used /// to determine whether two "P"'s represent the same vertex. /// @@ -38,4 +38,3 @@ public IEnumerable

Vertices } } } - diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/GraphBuilder.ForEach.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/GraphBuilder.ForEach.cs index 5fa18aea5886b..f69af25b836f5 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/GraphBuilder.ForEach.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/GraphBuilder.ForEach.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; using System.Diagnostics; using Internal.TypeSystem; @@ -18,10 +16,10 @@ private sealed partial class GraphBuilder /// Walk through the type expression and find any embedded generic parameter references. For each one found, /// invoke the collector delegate with that generic parameter and a boolean indicate whether this is /// a proper embedding (i.e. there is something actually nesting this.) - /// + /// /// Typically, the type expression is something that a generic type formal is being bound to, and we're /// looking to see if another other generic type formals are referenced within that type expression. - /// + /// /// This method also records bindings for any generic instances it finds inside the tree expression. /// Sometimes, this side-effect is all that's wanted - in such cases, invoke this method with a null collector. ///

@@ -31,8 +29,7 @@ private void ForEachEmbeddedGenericFormal(TypeDesc typeExpression, Instantiation delegate(EcmaGenericParameter embedded, int depth) { bool isProperEmbedding = (depth > 0); - if (collector != null) - collector(embedded, isProperEmbedding); + collector?.Invoke(embedded, isProperEmbedding); return; }; ForEachEmbeddedGenericFormalWorker(typeExpression, typeContext, methodContext, wrappedCollector, depth: 0); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/GraphBuilder.MethodCall.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/GraphBuilder.MethodCall.cs index 5ddd13772827a..2eb785fb72ab4 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/GraphBuilder.MethodCall.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/GraphBuilder.MethodCall.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Generic; using System.Diagnostics; using Internal.TypeSystem; @@ -49,7 +48,7 @@ private void ProcessMethodCall(MethodDesc target, Instantiation typeContext, Ins delegate(EcmaGenericParameter embedded, bool isProperEmbedding) { // If we got here, we found a method with generic arity (either from itself or its declaring type or both) - // that invokes a generic method. The caller is binding one of the target's generic formals to a type expression + // that invokes a generic method. The caller is binding one of the target's generic formals to a type expression // involving one of the caller's own formals. // // e.g. diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/GraphBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/GraphBuilder.cs index 7d072ef4d3efb..408d35fbe87a9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/GraphBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/GraphBuilder.cs @@ -18,7 +18,7 @@ public GraphBuilder(EcmaModule assembly) { _graph = new Graph(); _metadataReader = assembly.MetadataReader; - + foreach (TypeDefinitionHandle typeHandle in _metadataReader.TypeDefinitions) { TypeDefinition typeDefinition = _metadataReader.GetTypeDefinition(typeHandle); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/ModuleCycleInfo.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/ModuleCycleInfo.cs index cfbfe6d7a5e47..9a3649c203810 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/ModuleCycleInfo.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/ModuleCycleInfo.cs @@ -16,7 +16,7 @@ namespace ILCompiler { internal static partial class LazyGenericsSupport { - private class ModuleCycleInfo + private sealed class ModuleCycleInfo { private readonly HashSet _entitiesInCycles; @@ -38,7 +38,7 @@ public bool FormsCycle(TypeSystemEntity owner) } } - private class CycleInfoHashtable : LockFreeReaderHashtable + private sealed class CycleInfoHashtable : LockFreeReaderHashtable { protected override bool CompareKeyToValue(EcmaModule key, ModuleCycleInfo value) => key == value.Module; protected override bool CompareValueToValue(ModuleCycleInfo value1, ModuleCycleInfo value2) => value1.Module == value2.Module; @@ -70,7 +70,7 @@ protected override ModuleCycleInfo CreateValueFromKey(EcmaModule key) } } - internal class GenericCycleDetector + internal sealed class GenericCycleDetector { private readonly CycleInfoHashtable _hashtable = new CycleInfoHashtable(); @@ -215,8 +215,6 @@ public void DetectCycle(TypeSystemEntity owner, TypeSystemEntity referent) public void LogWarnings(Logger logger) { - var problems = new List>(_actualProblems); - // Might need to sort these if we care about warning determinism, but we probably don't. var reportedProblems = new HashSet(); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LibraryRootProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LibraryRootProvider.cs index 35ef0b337ce89..00fb2285f85d5 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LibraryRootProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LibraryRootProvider.cs @@ -47,7 +47,7 @@ public void AddCompilationRoots(IRootingServiceProvider rootProvider) } } - private void RootMethods(TypeDesc type, string reason, IRootingServiceProvider rootProvider) + private static void RootMethods(TypeDesc type, string reason, IRootingServiceProvider rootProvider) { foreach (MethodDesc method in type.GetAllMethods()) { @@ -77,7 +77,7 @@ private void RootMethods(TypeDesc type, string reason, IRootingServiceProvider r } /// - /// Validates that it will be possible to generate '' based on the types + /// Validates that it will be possible to generate '' based on the types /// in its signature. Unresolvable types in a method's signature prevent RyuJIT from generating /// even a stubbed out throwing implementation. /// @@ -101,10 +101,7 @@ private static void CheckTypeCanBeUsedInSignature(TypeDesc type) { MetadataType defType = type as MetadataType; - if (defType != null) - { - defType.ComputeTypeContainsGCPointers(); - } + defType?.ComputeTypeContainsGCPointers(); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logger.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logger.cs index fac33d4b58cbc..84a6782564427 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logger.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logger.cs @@ -13,8 +13,6 @@ using ILCompiler.Dataflow; using ILCompiler.Logging; using ILLink.Shared; - -using ILSequencePoint = Internal.IL.ILSequencePoint; using MethodIL = Internal.IL.MethodIL; using Internal.IL; @@ -177,7 +175,7 @@ internal bool IsWarningSuppressed(int code, MessageOrigin origin) return false; } - bool IsSuppressed(int id, TypeSystemEntity warningOrigin) + private static bool IsSuppressed(int id, TypeSystemEntity warningOrigin) { TypeSystemEntity warningOriginMember = warningOrigin; while (warningOriginMember != null) @@ -193,7 +191,7 @@ bool IsSuppressed(int id, TypeSystemEntity warningOrigin) return false; } - bool IsSuppressedOnElement(int id, TypeSystemEntity provider) + private static bool IsSuppressedOnElement(int id, TypeSystemEntity provider) { if (provider == null) return false; @@ -223,7 +221,7 @@ bool IsSuppressedOnElement(int id, TypeSystemEntity provider) || warningId.Length < 6 || !warningId.StartsWith("IL") || (warningId.Length > 6 && warningId[6] != ':') - || !int.TryParse(warningId.Substring(2, 4), out int suppressedCode)) + || !int.TryParse(warningId.AsSpan(2, 4), out int suppressedCode)) { continue; } @@ -238,7 +236,7 @@ bool IsSuppressedOnElement(int id, TypeSystemEntity provider) return false; } - internal bool IsWarningAsError(int code) + internal static bool IsWarningAsError(int code) { // TODO: warnaserror return false; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureGenerator.PartVisitor.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureGenerator.PartVisitor.cs index fbb5ec5749ce2..10122ce083e07 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureGenerator.PartVisitor.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureGenerator.PartVisitor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Diagnostics; using System.Text; @@ -134,7 +133,7 @@ public override void AppendName(StringBuilder builder, GenericParameterDesc gene // If the containing type is nested within other types. // e.g. A.B.M(T t, U u, V v) should be M(`0, `1, ``0). - // Roslyn needs to add generic arities of parents, but the innermost type redeclares + // Roslyn needs to add generic arities of parents, but the innermost type redeclares // all generic parameters so we don't need to add them. builder.Append('`'); } @@ -178,7 +177,7 @@ protected override void AppendNameForInstantiatedType(StringBuilder builder, Def string unmangledName = type.Name; int totalArity = type.Instantiation.Length; - string expectedSuffix = $"`{totalArity.ToString()}"; + string expectedSuffix = $"`{totalArity}"; if (unmangledName.EndsWith(expectedSuffix)) unmangledName = unmangledName.Substring(0, unmangledName.Length - expectedSuffix.Length); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs index 3a9e7cf8768c3..640adbc7a8435 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System; using System.Collections.Generic; @@ -54,7 +53,7 @@ public static TypeDesc GetTypeByDocumentationSignature(IAssemblyDesc assembly, s { int index = 0; var results = new List(); - DocumentationSignatureParser.ParseSignaturePart(signature, ref index, (ModuleDesc)assembly, DocumentationSignatureParser.MemberType.Type, results); + ParseSignaturePart(signature, ref index, (ModuleDesc)assembly, MemberType.Type, results); Debug.Assert(results.Count <= 1); return results.Count == 0 ? null : (TypeDesc)results[0]; } @@ -65,19 +64,19 @@ public static IEnumerable GetMembersByDocumentationSignature(M int index = 0; var results = new List(); var nameBuilder = new StringBuilder(); - var (name, arity) = DocumentationSignatureParser.ParseTypeOrNamespaceName(signature, ref index, nameBuilder); - DocumentationSignatureParser.GetMatchingMembers(signature, ref index, type.Module, type, name, arity, DocumentationSignatureParser.MemberType.All, results, acceptName); + var (name, arity) = ParseTypeOrNamespaceName(signature, ref index, nameBuilder); + GetMatchingMembers(signature, ref index, type.Module, type, name, arity, MemberType.All, results, acceptName); return results; } - static string GetSignaturePart(TypeDesc type) + private static string GetSignaturePart(TypeDesc type) { var builder = new StringBuilder(); DocumentationSignatureGenerator.PartVisitor.Instance.AppendName(builder, type); return builder.ToString(); } - static bool ParseDocumentationSignature(string id, ModuleDesc module, List results) + private static bool ParseDocumentationSignature(string id, ModuleDesc module, List results) { if (id == null) return false; @@ -91,7 +90,7 @@ static bool ParseDocumentationSignature(string id, ModuleDesc module, List 0; } - static void ParseSignature(string id, ref int index, ModuleDesc module, List results) + private static void ParseSignature(string id, ref int index, ModuleDesc module, List results) { Debug.Assert(results.Count == 0); var memberTypeChar = PeekNextChar(id, index); @@ -150,7 +149,7 @@ public static void ParseSignaturePart(string id, ref int index, ModuleDesc modul (name, arity) = ParseTypeOrNamespaceName(id, ref index, nameBuilder); // if we are at the end of the dotted name and still haven't resolved it to // a type, there are no results. - if (String.IsNullOrEmpty(name)) + if (string.IsNullOrEmpty(name)) return; // no more dots, so don't loop any more @@ -276,7 +275,7 @@ public static (string name, int arity) ParseTypeOrNamespaceName(string id, ref i // To avoid looking for types by name in all referenced assemblies, we just represent types // that are part of a signature by their doc comment strings, and we check for matching // strings when looking for matching member signatures. - static string ParseTypeSymbol(string id, ref int index, TypeSystemEntity typeParameterContext) + private static string ParseTypeSymbol(string id, ref int index, TypeSystemEntity typeParameterContext) { var results = new List(); ParseTypeSymbol(id, ref index, typeParameterContext, results); @@ -287,7 +286,7 @@ static string ParseTypeSymbol(string id, ref int index, TypeSystemEntity typePar return null; } - static void ParseTypeSymbol(string id, ref int index, TypeSystemEntity typeParameterContext, List results) + private static void ParseTypeSymbol(string id, ref int index, TypeSystemEntity typeParameterContext, List results) { // Note: Roslyn has a special case that deviates from the language spec, which // allows context expressions embedded in a type reference => : @@ -348,7 +347,7 @@ static void ParseTypeSymbol(string id, ref int index, TypeSystemEntity typeParam index = endIndex; } - static void ParseTypeParameterSymbol(string id, ref int index, TypeSystemEntity typeParameterContext, List results) + private static void ParseTypeParameterSymbol(string id, ref int index, TypeSystemEntity typeParameterContext, List results) { // skip the first ` Debug.Assert(PeekNextChar(id, index) == '`'); @@ -393,7 +392,7 @@ typeParameterContext is TypeDesc } } - static void ParseNamedTypeSymbol(string id, ref int index, TypeSystemEntity typeParameterContext, List results) + private static void ParseNamedTypeSymbol(string id, ref int index, TypeSystemEntity typeParameterContext, List results) { Debug.Assert(results.Count == 0); var nameBuilder = new StringBuilder(); @@ -401,7 +400,7 @@ static void ParseNamedTypeSymbol(string id, ref int index, TypeSystemEntity type while (true) { var name = ParseName(id, ref index); - if (String.IsNullOrEmpty(name)) + if (string.IsNullOrEmpty(name)) return; nameBuilder.Append(name); @@ -448,7 +447,7 @@ static void ParseNamedTypeSymbol(string id, ref int index, TypeSystemEntity type results.Add(nameBuilder.ToString()); } - static int ParseArrayBounds(string id, ref int index) + private static int ParseArrayBounds(string id, ref int index) { index++; // skip '[' @@ -491,7 +490,7 @@ static int ParseArrayBounds(string id, ref int index) return bounds; } - static bool ParseTypeArguments(string id, ref int index, TypeSystemEntity typeParameterContext, List typeArguments) + private static bool ParseTypeArguments(string id, ref int index, TypeSystemEntity typeParameterContext, List typeArguments) { index++; // skip over { @@ -526,7 +525,7 @@ static bool ParseTypeArguments(string id, ref int index, TypeSystemEntity typePa return true; } - static void GetMatchingTypes(ModuleDesc module, TypeDesc declaringType, string name, int arity, List results) + private static void GetMatchingTypes(ModuleDesc module, TypeDesc declaringType, string name, int arity, List results) { Debug.Assert(module != null); @@ -559,7 +558,7 @@ static void GetMatchingTypes(ModuleDesc module, TypeDesc declaringType, string n foreach (var nestedType in mdDeclaringType.GetNestedTypes()) { - Debug.Assert(String.IsNullOrEmpty(nestedType.Namespace)); + Debug.Assert(string.IsNullOrEmpty(nestedType.Namespace)); if (nestedType.Name != name) continue; @@ -575,7 +574,7 @@ static void GetMatchingTypes(ModuleDesc module, TypeDesc declaringType, string n } } - static void GetMatchingMethods(string id, ref int index, TypeDesc type, string memberName, int arity, List results, bool acceptName = false) + private static void GetMatchingMethods(string id, ref int index, TypeDesc type, string memberName, int arity, List results, bool acceptName = false) { if (type == null) return; @@ -677,7 +676,7 @@ static void GetMatchingProperties(string id, ref int index, TypeDesc type, strin } #endif - static void GetMatchingFields(TypeDesc type, string memberName, List results) + private static void GetMatchingFields(TypeDesc type, string memberName, List results) { if (type == null) return; @@ -703,7 +702,7 @@ static void GetMatchingEvents(TypeDesc type, string memberName, List expectedParameters) + private static bool AllParametersMatch(MethodSignature methodParameters, List expectedParameters) { if (methodParameters.Length != expectedParameters.Count) return false; @@ -717,9 +716,9 @@ static bool AllParametersMatch(MethodSignature methodParameters, List ex return true; } - static bool ParseParameterList(string id, ref int index, TypeSystemEntity typeParameterContext, List parameters) + private static bool ParseParameterList(string id, ref int index, TypeSystemEntity typeParameterContext, List parameters) { - System.Diagnostics.Debug.Assert(typeParameterContext != null); + Debug.Assert(typeParameterContext != null); index++; // skip over '(' @@ -756,14 +755,14 @@ static bool ParseParameterList(string id, ref int index, TypeSystemEntity typePa return true; } - static char PeekNextChar(string id, int index) + private static char PeekNextChar(string id, int index) { return index >= id.Length ? '\0' : id[index]; } - static readonly char[] s_nameDelimiters = { ':', '.', '(', ')', '{', '}', '[', ']', ',', '\'', '@', '*', '`', '~' }; + private static readonly char[] s_nameDelimiters = { ':', '.', '(', ')', '{', '}', '[', ']', ',', '\'', '@', '*', '`', '~' }; - static string ParseName(string id, ref int index) + private static string ParseName(string id, ref int index) { string name; @@ -783,12 +782,12 @@ static string ParseName(string id, ref int index) } // undoes dot encodings within names... - static string DecodeName(string name) + private static string DecodeName(string name) { return name.Replace('#', '.'); } - static int ReadNextInteger(string id, ref int index) + private static int ReadNextInteger(string id, ref int index) { int n = 0; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/MessageContainer.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/MessageContainer.cs index 8f6e4f33efd2f..733347fe0b8f3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/MessageContainer.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/MessageContainer.cs @@ -131,7 +131,7 @@ internal static MessageContainer CreateErrorMessage(MessageOrigin? origin, Diagn if (TryLogSingleWarning(context, code, origin, subcategory)) return null; - if (context.IsWarningAsError(code)) + if (Logger.IsWarningAsError(code)) return new MessageContainer(MessageCategory.WarningAsError, text, code, subcategory, origin); return new MessageContainer(MessageCategory.Warning, text, code, subcategory, origin); @@ -148,7 +148,7 @@ internal static MessageContainer CreateErrorMessage(MessageOrigin? origin, Diagn if (TryLogSingleWarning(context, (int)id, origin, subcategory)) return null; - if (context.IsWarningAsError((int)id)) + if (Logger.IsWarningAsError((int)id)) return new MessageContainer(MessageCategory.WarningAsError, id, subcategory, origin, args); return new MessageContainer(MessageCategory.Warning, id, subcategory, origin, args); @@ -265,10 +265,10 @@ public string ToMSBuildString() string origin = Origin?.ToString() ?? originApp; StringBuilder sb = new StringBuilder(); - sb.Append(origin).Append(":"); + sb.Append(origin).Append(':'); if (!string.IsNullOrEmpty(SubCategory)) - sb.Append(" ").Append(SubCategory); + sb.Append(' ').Append(SubCategory); string cat; switch (Category) @@ -287,7 +287,7 @@ public string ToMSBuildString() if (!string.IsNullOrEmpty(cat)) { - sb.Append(" ") + sb.Append(' ') .Append(cat) .Append(" IL") .Append(Code.Value.ToString("D4")) @@ -295,7 +295,7 @@ public string ToMSBuildString() } else { - sb.Append(" "); + sb.Append(' '); } if (Origin?.MemberDefinition != null) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/MessageOrigin.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/MessageOrigin.cs index b2d002cca090f..8590ab5b2fb6e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/MessageOrigin.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/MessageOrigin.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Reflection.Metadata; using System.Text; using Internal.IL; using Internal.TypeSystem; @@ -82,11 +81,11 @@ public MessageOrigin WithInstructionOffset(MethodIL methodBody, int ilOffset) StringBuilder sb = new StringBuilder(FileName); if (SourceLine.HasValue) { - sb.Append("(").Append(SourceLine); + sb.Append('(').Append(SourceLine); if (SourceColumn.HasValue) - sb.Append(",").Append(SourceColumn); + sb.Append(',').Append(SourceColumn); - sb.Append(")"); + sb.Append(')'); } return sb.ToString(); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ManifestResourceBlockingPolicy.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ManifestResourceBlockingPolicy.cs index 3b2b3a2e25384..325368c2abe88 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ManifestResourceBlockingPolicy.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ManifestResourceBlockingPolicy.cs @@ -39,7 +39,7 @@ public virtual bool IsManifestResourceBlocked(ModuleDesc module, string resource || (resourceName.StartsWith("ILLink.") && resourceName.EndsWith(".xml"))); } - private class FeatureSwitchHashtable : LockFreeReaderHashtable + private sealed class FeatureSwitchHashtable : LockFreeReaderHashtable { private readonly Dictionary _switchValues; @@ -59,7 +59,7 @@ protected override AssemblyFeatureInfo CreateValueFromKey(EcmaModule key) } } - private class AssemblyFeatureInfo + private sealed class AssemblyFeatureInfo { public EcmaModule Module { get; } @@ -100,7 +100,7 @@ public AssemblyFeatureInfo(EcmaModule module, IReadOnlyDictionary } } - private class SubstitutionsReader : ProcessXmlBase + private sealed class SubstitutionsReader : ProcessXmlBase { private readonly HashSet _substitutions = new HashSet(); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MetadataManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MetadataManager.cs index f2101a2e876a9..b63026dae37a7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MetadataManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MetadataManager.cs @@ -185,8 +185,7 @@ protected virtual void Graph_NewMarkedNode(DependencyNodeCore obj) _reflectableMethods.Add(methodNode.Method); } - if (methodNode == null) - methodNode = obj as ShadowConcreteMethodNode; + methodNode ??= obj as ShadowConcreteMethodNode; if (methodNode != null) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MstatObjectDumper.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MstatObjectDumper.cs index 0f0af381c2e6e..d0d804dfd9ef2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MstatObjectDumper.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MstatObjectDumper.cs @@ -14,7 +14,6 @@ using ObjectData = ILCompiler.DependencyAnalysis.ObjectNode.ObjectData; using AssemblyName = System.Reflection.AssemblyName; using System.Collections.Generic; -using static ILCompiler.DependencyAnalysis.ObjectNode; namespace ILCompiler { @@ -33,7 +32,7 @@ public class MstatObjectDumper : ObjectDumper private Dictionary _blobs = new(); private Utf8StringBuilder _utf8StringBuilder = new Utf8StringBuilder(); - + public MstatObjectDumper(string fileName, TypeSystemContext context) { _fileName = fileName; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MultiFileCompilationModuleGroup.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MultiFileCompilationModuleGroup.cs index ba9da7828607d..05888aebfef83 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MultiFileCompilationModuleGroup.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MultiFileCompilationModuleGroup.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using System.Diagnostics; @@ -111,7 +110,7 @@ public override bool ShouldPromoteToFullType(TypeDesc type) public override bool PresenceOfEETypeImpliesAllMethodsOnType(TypeDesc type) { - return (type.HasInstantiation || type.IsArray) && ShouldProduceFullVTable(type) && + return (type.HasInstantiation || type.IsArray) && ShouldProduceFullVTable(type) && type.ConvertToCanonForm(CanonicalFormKind.Specific).IsCanonicalSubtype(CanonicalFormKind.Any); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NativeLibraryInitializerRootProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NativeLibraryInitializerRootProvider.cs index 4b7c639400f64..759b9ca25ab5d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NativeLibraryInitializerRootProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NativeLibraryInitializerRootProvider.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; - -using Internal.TypeSystem.Ecma; using Internal.TypeSystem; using Internal.IL.Stubs.StartupCode; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NodeMangler.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NodeMangler.cs index ea9586de22de2..72110ed895d53 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NodeMangler.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NodeMangler.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Internal.Text; using Internal.TypeSystem; namespace ILCompiler @@ -10,7 +9,7 @@ namespace ILCompiler // NodeMangler is responsible for producing mangled names for specific nodes // and for node-related purposes, where the name needs to be in a special format // on some platform - // + // public abstract class NodeMangler { public NameMangler NameMangler; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectDumper.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectDumper.cs index 10d229da90c47..355f766040d87 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectDumper.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectDumper.cs @@ -1,11 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; -using Internal.Text; - using ILCompiler.DependencyAnalysis; using ObjectData = ILCompiler.DependencyAnalysis.ObjectNode.ObjectData; @@ -37,7 +34,7 @@ protected static string GetObjectNodeName(ObjectNode node) public static ObjectDumper Compose(IEnumerable dumpers) { - var dumpersList = new ArrayBuilder(); + var dumpersList = default(ArrayBuilder); foreach (var dumper in dumpers) dumpersList.Add(dumper); @@ -50,7 +47,7 @@ public static ObjectDumper Compose(IEnumerable dumpers) }; } - private class ComposedObjectDumper : ObjectDumper + private sealed class ComposedObjectDumper : ObjectDumper { private readonly ObjectDumper[] _dumpers; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/PreinitializationManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/PreinitializationManager.cs index 36630dccd29e9..c76c65e3a5ebb 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/PreinitializationManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/PreinitializationManager.cs @@ -8,7 +8,7 @@ namespace ILCompiler { /// - /// Manages policies around static constructors (.cctors) and static data initialization. + /// Manages policies around static constructors (.cctors) and static data initialization. /// public class PreinitializationManager { @@ -76,7 +76,7 @@ public bool HasEagerStaticConstructor(TypeDesc type) private static bool HasEagerConstructorAttribute(TypeDesc type) { MetadataType mdType = type as MetadataType; - return mdType != null && + return mdType != null && mdType.HasCustomAttribute("System.Runtime.CompilerServices", "EagerStaticClassConstructionAttribute"); } @@ -88,7 +88,7 @@ public bool IsPreinitialized(MetadataType type) if (!type.HasStaticConstructor) return false; - + // The cctor on the Module type is the module constructor. That's special. if (type.IsModuleType) return false; @@ -133,7 +133,7 @@ public TypePreinit.PreinitializationInfo GetPreinitializationInfo(MetadataType t return _preinitHashTable.GetOrCreateValue(type); } - class PreinitializationInfoHashtable : LockFreeReaderHashtable + private sealed class PreinitializationInfoHashtable : LockFreeReaderHashtable { private readonly CompilationModuleGroup _compilationGroup; private readonly ILProvider _ilProvider; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ProcessLinkerXmlBase.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ProcessLinkerXmlBase.cs index ed595e1d808cd..c72529b6dfdb6 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ProcessLinkerXmlBase.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ProcessLinkerXmlBase.cs @@ -32,20 +32,20 @@ public enum AllowedAssemblies public abstract class ProcessLinkerXmlBase { - const string FullNameAttributeName = "fullname"; - const string LinkerElementName = "linker"; - const string TypeElementName = "type"; - const string SignatureAttributeName = "signature"; - const string NameAttributeName = "name"; - const string FieldElementName = "field"; - const string MethodElementName = "method"; - const string EventElementName = "event"; - const string PropertyElementName = "property"; - const string AllAssembliesFullName = "*"; + private const string FullNameAttributeName = "fullname"; + private const string LinkerElementName = "linker"; + private const string TypeElementName = "type"; + private const string SignatureAttributeName = "signature"; + private const string NameAttributeName = "name"; + private const string FieldElementName = "field"; + private const string MethodElementName = "method"; + private const string EventElementName = "event"; + private const string PropertyElementName = "property"; + private const string AllAssembliesFullName = "*"; protected const string XmlNamespace = ""; protected readonly string _xmlDocumentLocation; - readonly XPathNavigator _document; + private readonly XPathNavigator _document; protected readonly ModuleDesc? _owningModule; private readonly IReadOnlyDictionary _featureSwitchValues; protected readonly TypeSystemContext _context; @@ -107,7 +107,7 @@ protected virtual void ProcessXml(bool ignoreResource) protected virtual AllowedAssemblies AllowedAssemblySelector { get => _owningModule != null ? AllowedAssemblies.ContainingAssembly : AllowedAssemblies.AnyAssembly; } - bool ShouldProcessAllAssemblies(XPathNavigator nav, [NotNullWhen(false)] out AssemblyName? assemblyName) + private bool ShouldProcessAllAssemblies(XPathNavigator nav, [NotNullWhen(false)] out AssemblyName? assemblyName) { assemblyName = null; if (GetFullName(nav) == AllAssembliesFullName) @@ -207,7 +207,7 @@ protected virtual void ProcessTypes(ModuleDesc assembly, XPathNavigator nav, boo } } - void MatchType(TypeDesc type, Regex regex, XPathNavigator nav) + private void MatchType(TypeDesc type, Regex regex, XPathNavigator nav) { StringBuilder sb = new StringBuilder(); CecilTypeNameFormatter.Instance.AppendName(sb, type); @@ -238,7 +238,7 @@ protected void ProcessTypeChildren(TypeDesc type, XPathNavigator nav, object? cu } } - void ProcessSelectedFields(XPathNavigator nav, TypeDesc type) + private void ProcessSelectedFields(XPathNavigator nav, TypeDesc type) { foreach (XPathNavigator fieldNav in nav.SelectChildren(FieldElementName, XmlNamespace)) { @@ -251,7 +251,7 @@ void ProcessSelectedFields(XPathNavigator nav, TypeDesc type) protected virtual void ProcessField(TypeDesc type, XPathNavigator nav) { string signature = GetSignature(nav); - if (!String.IsNullOrEmpty(signature)) + if (!string.IsNullOrEmpty(signature)) { FieldDesc? field = GetField(type, signature); if (field == null) @@ -264,7 +264,7 @@ protected virtual void ProcessField(TypeDesc type, XPathNavigator nav) } string name = GetName(nav); - if (!String.IsNullOrEmpty(name)) + if (!string.IsNullOrEmpty(name)) { bool foundMatch = false; foreach (FieldDesc field in type.GetFields()) @@ -300,7 +300,7 @@ protected virtual void ProcessField(TypeDesc type, XPathNavigator nav) protected virtual void ProcessField(TypeDesc type, FieldDesc field, XPathNavigator nav) { } - void ProcessSelectedMethods(XPathNavigator nav, TypeDesc type, object? customData) + private void ProcessSelectedMethods(XPathNavigator nav, TypeDesc type, object? customData) { foreach (XPathNavigator methodNav in nav.SelectChildren(MethodElementName, XmlNamespace)) { @@ -313,7 +313,7 @@ void ProcessSelectedMethods(XPathNavigator nav, TypeDesc type, object? customDat protected virtual void ProcessMethod(TypeDesc type, XPathNavigator nav, object? customData) { string signature = GetSignature(nav); - if (!String.IsNullOrEmpty(signature)) + if (!string.IsNullOrEmpty(signature)) { MethodDesc? method = GetMethod(type, signature); if (method == null) @@ -326,7 +326,7 @@ protected virtual void ProcessMethod(TypeDesc type, XPathNavigator nav, object? } string name = GetAttribute(nav, NameAttributeName); - if (!String.IsNullOrEmpty(name)) + if (!string.IsNullOrEmpty(name)) { bool foundMatch = false; foreach (MethodDesc method in type.GetAllMethods()) @@ -348,7 +348,7 @@ protected virtual void ProcessMethod(TypeDesc type, XPathNavigator nav, object? protected virtual void ProcessMethod(TypeDesc type, MethodDesc method, XPathNavigator nav, object? customData) { } - void ProcessSelectedEvents(XPathNavigator nav, TypeDesc type, object? customData) + private void ProcessSelectedEvents(XPathNavigator nav, TypeDesc type, object? customData) { foreach (XPathNavigator eventNav in nav.SelectChildren(EventElementName, XmlNamespace)) { @@ -361,7 +361,7 @@ void ProcessSelectedEvents(XPathNavigator nav, TypeDesc type, object? customData protected virtual void ProcessEvent(TypeDesc type, XPathNavigator nav, object? customData) { string signature = GetSignature(nav); - if (!String.IsNullOrEmpty(signature)) + if (!string.IsNullOrEmpty(signature)) { EventPseudoDesc? @event = GetEvent(type, signature); if (@event is null) @@ -374,7 +374,7 @@ protected virtual void ProcessEvent(TypeDesc type, XPathNavigator nav, object? c } string name = GetAttribute(nav, NameAttributeName); - if (!String.IsNullOrEmpty(name)) + if (!string.IsNullOrEmpty(name)) { bool foundMatch = false; if (type.GetTypeDefinition() is not EcmaType ecmaType) @@ -404,7 +404,7 @@ protected virtual void ProcessEvent(TypeDesc type, XPathNavigator nav, object? c protected virtual void ProcessEvent(TypeDesc type, EventPseudoDesc @event, XPathNavigator nav, object? customData) { } - void ProcessSelectedProperties(XPathNavigator nav, TypeDesc type, object? customData) + private void ProcessSelectedProperties(XPathNavigator nav, TypeDesc type, object? customData) { foreach (XPathNavigator propertyNav in nav.SelectChildren(PropertyElementName, XmlNamespace)) { @@ -417,7 +417,7 @@ void ProcessSelectedProperties(XPathNavigator nav, TypeDesc type, object? custom protected virtual void ProcessProperty(TypeDesc type, XPathNavigator nav, object? customData) { string signature = GetSignature(nav); - if (!String.IsNullOrEmpty(signature)) + if (!string.IsNullOrEmpty(signature)) { PropertyPseudoDesc? property = GetProperty(type, signature); if (property is null) @@ -430,7 +430,7 @@ protected virtual void ProcessProperty(TypeDesc type, XPathNavigator nav, object } string name = GetAttribute(nav, NameAttributeName); - if (!String.IsNullOrEmpty(name)) + if (!string.IsNullOrEmpty(name)) { bool foundMatch = false; foreach (PropertyPseudoDesc property in type.GetPropertiesOnTypeHierarchy(p => p.Name == name)) @@ -524,7 +524,7 @@ protected void LogWarning(XPathNavigator position, DiagnosticId id, params strin } #endif - class CecilTypeNameFormatter : TypeNameFormatter + private sealed class CecilTypeNameFormatter : TypeNameFormatter { public static readonly CecilTypeNameFormatter Instance = new CecilTypeNameFormatter(); @@ -550,22 +550,22 @@ public override void AppendName(StringBuilder sb, PointerType type) public override void AppendName(StringBuilder sb, FunctionPointerType type) { - sb.Append(" "); + sb.Append(' '); AppendName(sb, type.Signature.ReturnType); sb.Append(" *"); - sb.Append("("); + sb.Append('('); for (int i = 0; i < type.Signature.Length; i++) { var parameter = type.Signature[i]; if (i > 0) - sb.Append(","); + sb.Append(','); AppendName(sb, parameter); } - sb.Append(")"); + sb.Append(')'); } public override void AppendName(StringBuilder sb, GenericParameterDesc type) @@ -596,7 +596,7 @@ protected override void AppendNameForInstantiatedType(StringBuilder sb, DefType } protected override void AppendNameForNamespaceType(StringBuilder sb, DefType type) { - if (!String.IsNullOrEmpty(type.Namespace)) + if (!string.IsNullOrEmpty(type.Namespace)) { sb.Append(type.Namespace); sb.Append('.'); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ProcessXmlBase.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ProcessXmlBase.cs index b00f56a0c2ce4..11fb8e1c0c464 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ProcessXmlBase.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ProcessXmlBase.cs @@ -175,7 +175,7 @@ private void ProcessMethod(TypeDesc type) if (ShouldProcessElement()) { string signature = _reader.GetAttribute("signature"); - if (!String.IsNullOrEmpty(signature)) + if (!string.IsNullOrEmpty(signature)) { MethodDesc method = GetMethod(type, signature); if (method == null) @@ -188,7 +188,7 @@ private void ProcessMethod(TypeDesc type) } string methodName = _reader.GetAttribute("name"); - if (!String.IsNullOrEmpty(methodName)) + if (!string.IsNullOrEmpty(methodName)) { bool foundMatch = false; foreach (MethodDesc method in type.GetMethods()) @@ -217,7 +217,7 @@ private void ProcessField(TypeDesc type) if (ShouldProcessElement()) { string fieldName = _reader.GetAttribute("name"); - if (!String.IsNullOrEmpty(fieldName)) + if (!string.IsNullOrEmpty(fieldName)) { FieldDesc field = type.GetField(fieldName); @@ -245,7 +245,7 @@ protected virtual void ProcessResource(ModuleDesc module) { } - protected MethodDesc GetMethod(TypeDesc type, string signature) + protected static MethodDesc GetMethod(TypeDesc type, string signature) { foreach (MethodDesc meth in type.GetMethods()) if (signature == GetMethodSignature(meth, false)) @@ -312,7 +312,7 @@ private bool ShouldProcessElement() return bValue == featureSetting; } - class CecilTypeNameFormatter : TypeNameFormatter + private sealed class CecilTypeNameFormatter : TypeNameFormatter { public static readonly CecilTypeNameFormatter Instance = new CecilTypeNameFormatter(); @@ -338,22 +338,22 @@ public override void AppendName(StringBuilder sb, PointerType type) public override void AppendName(StringBuilder sb, FunctionPointerType type) { - sb.Append(" "); + sb.Append(' '); AppendName(sb, type.Signature.ReturnType); sb.Append(" *"); - sb.Append("("); + sb.Append('('); for (int i = 0; i < type.Signature.Length; i++) { var parameter = type.Signature[i]; if (i > 0) - sb.Append(","); + sb.Append(','); AppendName(sb, parameter); } - sb.Append(")"); + sb.Append(')'); } public override void AppendName(StringBuilder sb, GenericParameterDesc type) @@ -384,7 +384,7 @@ protected override void AppendNameForInstantiatedType(StringBuilder sb, DefType } protected override void AppendNameForNamespaceType(StringBuilder sb, DefType type) { - if (!String.IsNullOrEmpty(type.Namespace)) + if (!string.IsNullOrEmpty(type.Namespace)) { sb.Append(type.Namespace); sb.Append('.'); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RootingHelpers.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RootingHelpers.cs index 987e31fc03c27..cfe769b60e97c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RootingHelpers.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RootingHelpers.cs @@ -1,14 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Generic; - using Internal.TypeSystem; using ILCompiler.DependencyAnalysis; using DependencyList = ILCompiler.DependencyAnalysisFramework.DependencyNodeCore.DependencyList; -using Debug = System.Diagnostics.Debug; namespace ILCompiler { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RootingServiceProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RootingServiceProvider.cs index 8b105d762dab8..4beb7bf6204b6 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RootingServiceProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RootingServiceProvider.cs @@ -12,7 +12,7 @@ namespace ILCompiler { internal delegate void RootAdder(object o, string reason); - internal class RootingServiceProvider : IRootingServiceProvider + internal sealed class RootingServiceProvider : IRootingServiceProvider { private readonly NodeFactory _factory; private readonly RootAdder _rootAdder; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RuntimeConfigurationRootProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RuntimeConfigurationRootProvider.cs index 9a3facb6eeee1..122067c058710 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RuntimeConfigurationRootProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RuntimeConfigurationRootProvider.cs @@ -27,7 +27,7 @@ protected byte[] GetRuntimeOptionsBlob() { const int HeaderSize = 4; - ArrayBuilder options = new ArrayBuilder(); + ArrayBuilder options = default(ArrayBuilder); // Reserve space for the header options.ZeroExtend(HeaderSize); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TextLogWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TextLogWriter.cs index 7d04b75796490..7cda3de39f71d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TextLogWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TextLogWriter.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.IO; using ILCompiler.Logging; @@ -9,7 +8,7 @@ namespace ILCompiler { public class TextLogWriter : ILogWriter { - TextWriter _writer; + private TextWriter _writer; public TextLogWriter(TextWriter writer) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs index 15baf60300503..5d292226fbd72 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs @@ -1426,7 +1426,7 @@ private static Value NewUninitializedLocationValue(TypeDesc locationType) } } - private bool TryHandleIntrinsicCall(MethodDesc method, Value[] parameters, out Value retVal) + private static bool TryHandleIntrinsicCall(MethodDesc method, Value[] parameters, out Value retVal) { retVal = default; @@ -1450,7 +1450,7 @@ private bool TryHandleIntrinsicCall(MethodDesc method, Value[] parameters, out V return false; } - private TypeDesc GetArgType(MethodDesc method, int index) + private static TypeDesc GetArgType(MethodDesc method, int index) { var sig = method.Signature; int offset = 0; @@ -1467,7 +1467,7 @@ private TypeDesc GetArgType(MethodDesc method, int index) return sig[index - offset]; } - class Stack : Stack + private sealed class Stack : Stack { private readonly TargetDetails _target; @@ -1767,7 +1767,7 @@ public virtual bool TryCreateByRef(out Value value) public abstract void WriteFieldData(ref ObjectDataBuilder builder, NodeFactory factory); - private T ThrowInvalidProgram() + private static T ThrowInvalidProgram() { ThrowHelper.ThrowInvalidProgramException(); return default; @@ -1788,7 +1788,7 @@ private abstract class BaseValueTypeValue : Value } // Also represents pointers and function pointer. - private class ValueTypeValue : BaseValueTypeValue, IAssignableValue + private sealed class ValueTypeValue : BaseValueTypeValue, IAssignableValue { public readonly byte[] InstanceBytes; @@ -1878,7 +1878,7 @@ private byte[] AsExactByteCount(int size) public static ValueTypeValue FromDouble(double value) => new ValueTypeValue(BitConverter.GetBytes(value)); } - private class RuntimeFieldHandleValue : BaseValueTypeValue, IInternalModelingOnlyValue + private sealed class RuntimeFieldHandleValue : BaseValueTypeValue, IInternalModelingOnlyValue { public FieldDesc Field { get; private set; } @@ -1905,7 +1905,7 @@ public override void WriteFieldData(ref ObjectDataBuilder builder, NodeFactory f } } - private class MethodPointerValue : BaseValueTypeValue, IInternalModelingOnlyValue + private sealed class MethodPointerValue : BaseValueTypeValue, IInternalModelingOnlyValue { public MethodDesc PointedToMethod { get; } @@ -1932,7 +1932,7 @@ public override void WriteFieldData(ref ObjectDataBuilder builder, NodeFactory f } } - private class ByRefValue : Value, IHasInstanceFields + private sealed class ByRefValue : Value, IHasInstanceFields { public readonly byte[] PointedToBytes; public readonly int PointedToOffset; @@ -2024,7 +2024,9 @@ public override ReferenceTypeValue ToForeignInstance(int baseInstructionCounter) this); } +#pragma warning disable CA1852 private class DelegateInstance : AllocatedReferenceTypeValue, ISerializableReference +#pragma warning restore CA1852 { private readonly MethodDesc _methodPointed; private readonly ReferenceTypeValue _firstParameter; @@ -2095,7 +2097,9 @@ public override void WriteFieldData(ref ObjectDataBuilder builder, NodeFactory f } } +#pragma warning disable CA1852 private class ArrayInstance : AllocatedReferenceTypeValue, ISerializableReference +#pragma warning restore CA1852 { private readonly int _elementCount; private readonly int _elementSize; @@ -2181,7 +2185,7 @@ public virtual void WriteContent(ref ObjectDataBuilder builder, ISymbolNode this } } - private class ForeignTypeInstance : AllocatedReferenceTypeValue + private sealed class ForeignTypeInstance : AllocatedReferenceTypeValue { public ReferenceTypeValue Data { get; } @@ -2206,7 +2210,7 @@ public override void WriteFieldData(ref ObjectDataBuilder builder, NodeFactory f public override ReferenceTypeValue ToForeignInstance(int baseInstructionCounter) => this; } - private class StringInstance : ReferenceTypeValue + private sealed class StringInstance : ReferenceTypeValue { private readonly string _value; @@ -2224,7 +2228,9 @@ public override void WriteFieldData(ref ObjectDataBuilder builder, NodeFactory f public override ReferenceTypeValue ToForeignInstance(int baseInstructionCounter) => this; } +#pragma warning disable CA1852 private class ObjectInstance : AllocatedReferenceTypeValue, IHasInstanceFields, ISerializableReference +#pragma warning restore CA1852 { private readonly byte[] _data; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UniversalGenericsRootProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UniversalGenericsRootProvider.cs index 8788f375b65e5..19494506f7be3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UniversalGenericsRootProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UniversalGenericsRootProvider.cs @@ -11,7 +11,7 @@ namespace ILCompiler ///
public class UniversalGenericsRootProvider : ICompilationRootProvider { - TypeSystemContext _context; + private TypeSystemContext _context; public UniversalGenericsRootProvider(TypeSystemContext context) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UnixNodeMangler.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UnixNodeMangler.cs index 877f8da545d08..242759b0c9148 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UnixNodeMangler.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UnixNodeMangler.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Internal.Text; using Internal.TypeSystem; using System.Diagnostics; using System.Globalization; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedInteropStubManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedInteropStubManager.cs index fb80ee36e2d7b..822dfa2052740 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedInteropStubManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedInteropStubManager.cs @@ -4,14 +4,10 @@ using Internal.IL; using Internal.TypeSystem; using Internal.TypeSystem.Interop; - -using ILCompiler.Dataflow; using ILCompiler.DependencyAnalysis; -using ILLink.Shared; using Debug = System.Diagnostics.Debug; using DependencyList = ILCompiler.DependencyAnalysisFramework.DependencyNodeCore.DependencyList; -using System.Runtime.InteropServices; namespace ILCompiler { @@ -32,7 +28,7 @@ public override void AddDependenciesDueToMethodCodePresence(ref DependencyList d { if (method.HasInstantiation) { - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); AddMarshalAPIsGenericDependencies(ref dependencies, factory, method); } } @@ -44,7 +40,7 @@ public override void AddInterestingInteropConstructedTypeDependencies(ref Depend var delegateType = (MetadataType)type; if (delegateType.HasCustomAttribute("System.Runtime.InteropServices", "UnmanagedFunctionPointerAttribute")) { - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(factory.DelegateMarshallingData(delegateType), "Delegate marshalling"); } } @@ -74,7 +70,7 @@ public override void AddMarshalAPIsGenericDependencies(ref DependencyList depend { foreach (TypeDesc type in method.Instantiation) { - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); if (type.IsDelegate) { dependencies.Add(factory.DelegateMarshallingData((DefType)type), "Delegate marshlling"); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedMetadataManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedMetadataManager.cs index 53b92c2eaaee3..b194f26594485 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedMetadataManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedMetadataManager.cs @@ -26,7 +26,6 @@ using EcmaModule = Internal.TypeSystem.Ecma.EcmaModule; using EcmaType = Internal.TypeSystem.Ecma.EcmaType; using FlowAnnotations = ILLink.Shared.TrimAnalysis.FlowAnnotations; -using MetadataExtensions = Internal.TypeSystem.Ecma.MetadataExtensions; namespace ILCompiler { @@ -211,13 +210,13 @@ protected override void ComputeMetadata(NodeFactory factory, protected override void GetMetadataDependenciesDueToReflectability(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(factory.MethodMetadata(method.GetTypicalMethodDefinition()), "Reflectable method"); } protected override void GetMetadataDependenciesDueToReflectability(ref DependencyList dependencies, NodeFactory factory, FieldDesc field) { - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(factory.FieldMetadata(field.GetTypicalFieldDefinition()), "Reflectable field"); } @@ -230,8 +229,6 @@ internal override void GetDependenciesDueToModuleUse(ref DependencyList dependen } if (module is EcmaModule ecmaModule) { - PEMemoryBlock resourceDirectory = ecmaModule.PEReader.GetSectionData(ecmaModule.PEReader.PEHeaders.CorHeader.ResourcesDirectory.RelativeVirtualAddress); - foreach (var resourceHandle in ecmaModule.MetadataReader.ManifestResources) { ManifestResource resource = ecmaModule.MetadataReader.GetManifestResource(resourceHandle); @@ -287,7 +284,7 @@ protected override void GetMetadataDependenciesDueToReflectability(ref Dependenc { if (!method.Signature.IsStatic && method.IsSpecialName) { - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(factory.CanonicalEntrypoint(method), "Anonymous type accessor"); } } @@ -335,7 +332,7 @@ protected override void GetMetadataDependenciesDueToReflectability(ref Dependenc if (fullyRoot) { - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); var rootProvider = new RootingServiceProvider(factory, dependencies.Add); foreach (TypeDesc t in mdType.Module.GetAllTypes()) { @@ -351,12 +348,12 @@ protected override void GetMetadataDependenciesDueToReflectability(ref Dependenc AddEventSourceSpecialTypeDependencies(ref dependencies, factory, mdType.GetNestedType("Tasks")); AddEventSourceSpecialTypeDependencies(ref dependencies, factory, mdType.GetNestedType("Opcodes")); - void AddEventSourceSpecialTypeDependencies(ref DependencyList dependencies, NodeFactory factory, MetadataType type) + static void AddEventSourceSpecialTypeDependencies(ref DependencyList dependencies, NodeFactory factory, MetadataType type) { if (type != null) { const string reason = "Event source"; - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(factory.TypeMetadata(type), reason); foreach (FieldDesc field in type.GetFields()) { @@ -507,14 +504,14 @@ public override void GetDependenciesDueToLdToken(ref DependencyList dependencies { if (!IsReflectionBlocked(field)) { - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(factory.ReflectableField(field), "LDTOKEN field"); } } public override void GetDependenciesDueToLdToken(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); if (!IsReflectionBlocked(method)) dependencies.Add(factory.ReflectableMethod(method), "LDTOKEN method"); @@ -524,7 +521,7 @@ public override void GetDependenciesDueToDelegateCreation(ref DependencyList dep { if (!IsReflectionBlocked(target)) { - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(factory.ReflectableMethod(target), "Target of a delegate"); } } @@ -646,7 +643,7 @@ public override void GetDependenciesDueToVirtualMethodReflectability(ref Depende // for the metadata manager. Metadata manager treats that node the same as a body. if (method.IsAbstract && GetMetadataCategory(method) != 0) { - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(factory.ReflectableMethod(method), "Abstract reflectable method"); } } @@ -739,7 +736,7 @@ public override void GetDependenciesDueToAccess(ref DependencyList dependencies, } } - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(factory.ReflectableField(fieldToReport), reason); } } @@ -983,7 +980,7 @@ private void AddDataflowDependency(ref DependencyList dependencies, NodeFactory if (CompilerGeneratedState.IsNestedFunctionOrStateMachineMember(methodILDefinition.OwningMethod)) return; - dependencies = dependencies ?? new DependencyList(); + dependencies ??= new DependencyList(); dependencies.Add(factory.DataflowAnalyzedMethod(methodILDefinition), reason); } @@ -1078,7 +1075,7 @@ public bool IsBlocked(MethodDesc methodDef) } } - private class FeatureSwitchHashtable : LockFreeReaderHashtable + private sealed class FeatureSwitchHashtable : LockFreeReaderHashtable { private readonly Dictionary _switchValues; @@ -1098,7 +1095,7 @@ protected override AssemblyFeatureInfo CreateValueFromKey(EcmaModule key) } } - private class AssemblyFeatureInfo + private sealed class AssemblyFeatureInfo { public EcmaModule Module { get; } @@ -1139,7 +1136,7 @@ public AssemblyFeatureInfo(EcmaModule module, IReadOnlyDictionary } } - private class LinkAttributesReader : ProcessXmlBase + private sealed class LinkAttributesReader : ProcessXmlBase { private readonly HashSet _removedAttributes; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs index 6dd4e08ff2e33..68cae05dd66f3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Reflection.Metadata; -using System.Reflection.Metadata.Ecma335; using Internal.TypeSystem; using Internal.TypeSystem.Ecma; @@ -17,14 +16,14 @@ namespace ILCompiler { public class UserDefinedTypeDescriptor { - object _lock = new object(); - NodeFactory _nodeFactory; + private object _lock = new object(); + private NodeFactory _nodeFactory; - NodeFactory NodeFactory => _nodeFactory; + private NodeFactory NodeFactory => _nodeFactory; - bool Is64Bit => NodeFactory.Target.PointerSize == 8; + private bool Is64Bit => NodeFactory.Target.PointerSize == 8; - TargetAbi Abi => NodeFactory.Target.Abi; + private TargetAbi Abi => NodeFactory.Target.Abi; public UserDefinedTypeDescriptor(ITypesDebugInfoWriter objectWriter, NodeFactory nodeFactory) { @@ -66,7 +65,7 @@ public uint GetStateMachineThisVariableTypeIndex(TypeDesc type) InstanceSize = defType.InstanceByteCount.IsIndeterminate ? 0 : (ulong)defType.InstanceByteCount.AsInt, }; - var fieldsDescs = new ArrayBuilder(); + var fieldsDescs = default(ArrayBuilder); foreach (var fieldDesc in defType.GetFields()) { @@ -166,7 +165,7 @@ public uint GetThisTypeIndex(TypeDesc type) if (_thisTypes.TryGetValue(type, out typeIndex)) return typeIndex; - PointerTypeDescriptor descriptor = new PointerTypeDescriptor(); + PointerTypeDescriptor descriptor = default(PointerTypeDescriptor); // Note the use of GetTypeIndex here instead of GetVariableTypeIndex (We need the type exactly, not a reference to the type (as would happen for arrays/classes), and not a primitive value (as would happen for primitives)) descriptor.ElementType = GetTypeIndex(type, true); descriptor.Is64Bit = Is64Bit ? 1 : 0; @@ -189,7 +188,7 @@ public uint GetMethodTypeIndex(MethodDesc method) if (_methodIndices.TryGetValue(method, out typeIndex)) return typeIndex; - MemberFunctionTypeDescriptor descriptor = new MemberFunctionTypeDescriptor(); + MemberFunctionTypeDescriptor descriptor = default(MemberFunctionTypeDescriptor); MethodSignature signature = method.Signature; descriptor.ReturnType = GetVariableTypeIndex(DebuggerCanonicalize(signature.ReturnType)); @@ -230,7 +229,7 @@ public uint GetMethodFunctionIdTypeIndex(MethodDesc method) if (_methodIdIndices.TryGetValue(method, out typeIndex)) return typeIndex; - MemberFunctionIdTypeDescriptor descriptor = new MemberFunctionIdTypeDescriptor(); + MemberFunctionIdTypeDescriptor descriptor = default(MemberFunctionIdTypeDescriptor); descriptor.MemberFunction = GetMethodTypeIndex(method); descriptor.ParentClass = GetTypeIndex(method.OwningType, true); @@ -242,7 +241,7 @@ public uint GetMethodFunctionIdTypeIndex(MethodDesc method) } } - private TypeDesc DebuggerCanonicalize(TypeDesc type) + private static TypeDesc DebuggerCanonicalize(TypeDesc type) { if (type.IsCanonicalSubtype(CanonicalFormKind.Any)) return type.ConvertToCanonForm(CanonicalFormKind.Specific); @@ -252,7 +251,7 @@ private TypeDesc DebuggerCanonicalize(TypeDesc type) private uint GetVariableTypeIndex(TypeDesc type, bool needsCompleteIndex) { - uint variableTypeIndex = 0; + uint variableTypeIndex; if (type.IsPrimitive) { variableTypeIndex = GetPrimitiveTypeIndex(type); @@ -263,9 +262,8 @@ private uint GetVariableTypeIndex(TypeDesc type, bool needsCompleteIndex) if ((type.IsDefType && !type.IsValueType) || type.IsArray) { - // The type index of a variable/field of a reference type is wrapped + // The type index of a variable/field of a reference type is wrapped // in a pointer, as these fields are really pointer fields, and the data is on the heap - variableTypeIndex = 0; if (_knownReferenceWrappedTypes.TryGetValue(type, out variableTypeIndex)) { return variableTypeIndex; @@ -274,7 +272,7 @@ private uint GetVariableTypeIndex(TypeDesc type, bool needsCompleteIndex) { uint typeindex = GetTypeIndex(type, false); - PointerTypeDescriptor descriptor = new PointerTypeDescriptor(); + PointerTypeDescriptor descriptor = default(PointerTypeDescriptor); descriptor.ElementType = typeindex; descriptor.Is64Bit = Is64Bit ? 1 : 0; descriptor.IsConst = 0; @@ -315,7 +313,7 @@ private uint GetVariableTypeIndex(TypeDesc type, bool needsCompleteIndex) /// public uint GetTypeIndex(TypeDesc type, bool needsCompleteType) { - uint typeIndex = 0; + uint typeIndex; if (needsCompleteType ? _completeKnownTypes.TryGetValue(type, out typeIndex) : _knownTypes.TryGetValue(type, out typeIndex)) @@ -362,7 +360,7 @@ private uint GetPointerTypeIndex(TypeDesc pointeeType) if (_pointerTypes.TryGetValue(pointeeType, out typeIndex)) return typeIndex; - PointerTypeDescriptor descriptor = new PointerTypeDescriptor(); + PointerTypeDescriptor descriptor = default(PointerTypeDescriptor); descriptor.ElementType = GetVariableTypeIndex(pointeeType, false); descriptor.Is64Bit = Is64Bit ? 1 : 0; descriptor.IsConst = 0; @@ -384,7 +382,7 @@ private uint GetByRefTypeIndex(TypeDesc pointeeType) if (_byRefTypes.TryGetValue(pointeeType, out typeIndex)) return typeIndex; - PointerTypeDescriptor descriptor = new PointerTypeDescriptor(); + PointerTypeDescriptor descriptor = default(PointerTypeDescriptor); descriptor.ElementType = GetVariableTypeIndex(pointeeType, false); descriptor.Is64Bit = Is64Bit ? 1 : 0; descriptor.IsConst = 0; @@ -401,9 +399,9 @@ private uint GetByRefTypeIndex(TypeDesc pointeeType) private uint GetEnumTypeIndex(TypeDesc type) { - System.Diagnostics.Debug.Assert(type.IsEnum, "GetEnumTypeIndex was called with wrong type"); + Debug.Assert(type.IsEnum, "GetEnumTypeIndex was called with wrong type"); DefType defType = type as DefType; - System.Diagnostics.Debug.Assert(defType != null, "GetEnumTypeIndex was called with non def type"); + Debug.Assert(defType != null, "GetEnumTypeIndex was called with non def type"); List fieldsDescriptors = new List(); foreach (var field in defType.GetFields()) { @@ -433,7 +431,7 @@ private uint GetEnumTypeIndex(TypeDesc type) private uint GetArrayTypeIndex(TypeDesc type) { - System.Diagnostics.Debug.Assert(type.IsArray, "GetArrayTypeIndex was called with wrong type"); + Debug.Assert(type.IsArray, "GetArrayTypeIndex was called with wrong type"); ArrayType arrayType = (ArrayType)type; uint elementSize = (uint)type.Context.Target.PointerSize; @@ -462,7 +460,7 @@ private uint GetArrayTypeIndex(TypeDesc type) return typeIndex; } - private ulong GetEnumRecordValue(FieldDesc field) + private static ulong GetEnumRecordValue(FieldDesc field) { var ecmaField = field as EcmaField; if (ecmaField != null) @@ -478,7 +476,7 @@ private ulong GetEnumRecordValue(FieldDesc field) return 0; } - private ulong HandleConstant(EcmaModule module, ConstantHandle constantHandle) + private static ulong HandleConstant(EcmaModule module, ConstantHandle constantHandle) { MetadataReader reader = module.MetadataReader; Constant constant = reader.GetConstant(constantHandle); @@ -502,17 +500,17 @@ private ulong HandleConstant(EcmaModule module, ConstantHandle constantHandle) case ConstantTypeCode.UInt64: return (ulong)blob.ReadUInt64(); } - System.Diagnostics.Debug.Assert(false); + Debug.Assert(false); return 0; } - bool ShouldUseCanonicalTypeRecord(TypeDesc type) + private bool ShouldUseCanonicalTypeRecord(TypeDesc type) { // TODO: check the type's generic complexity return type.GetGenericDepth() > NodeFactory.TypeSystemContext.GenericsConfig.MaxGenericDepthOfDebugRecord; } - TypeDesc GetDebugType(TypeDesc type) + private TypeDesc GetDebugType(TypeDesc type) { TypeDesc typeGenericComplexityInfo = type; @@ -522,7 +520,7 @@ TypeDesc GetDebugType(TypeDesc type) } // Types that have some canonical subtypes types should always be represented in normalized canonical form to the binder. - // Also, to avoid infinite generic recursion issues, attempt to use canonical form for fields with high generic complexity. + // Also, to avoid infinite generic recursion issues, attempt to use canonical form for fields with high generic complexity. if (type.IsCanonicalSubtype(CanonicalFormKind.Specific) || (typeGenericComplexityInfo is DefType defType) && ShouldUseCanonicalTypeRecord(defType)) { type = type.ConvertToCanonForm(CanonicalFormKind.Specific); @@ -543,7 +541,7 @@ TypeDesc GetDebugType(TypeDesc type) return type; } - TypeDesc GetFieldDebugType(FieldDesc field) + private TypeDesc GetFieldDebugType(FieldDesc field) { return GetDebugType(field.FieldType); } @@ -552,7 +550,7 @@ private uint GetClassTypeIndex(TypeDesc type, bool needsCompleteType) { TypeDesc debugType = GetDebugType(type); DefType defType = debugType as DefType; - System.Diagnostics.Debug.Assert(defType != null, "GetClassTypeIndex was called with non def type"); + Debug.Assert(defType != null, "GetClassTypeIndex was called with non def type"); ClassTypeDescriptor classTypeDescriptor = new ClassTypeDescriptor { IsStruct = type.IsValueType ? 1 : 0, @@ -795,7 +793,7 @@ private void InsertStaticFieldRegionMember(List fieldDescs, } else if (staticDataInObject)// This means that access to this static region is done via indirection { - PointerTypeDescriptor pointerTypeDescriptor = new PointerTypeDescriptor(); + PointerTypeDescriptor pointerTypeDescriptor = default(PointerTypeDescriptor); pointerTypeDescriptor.Is64Bit = Is64Bit ? 1 : 0; pointerTypeDescriptor.IsConst = 0; pointerTypeDescriptor.IsReference = 0; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/VectorOfTFieldLayoutAlgorithm.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/VectorOfTFieldLayoutAlgorithm.cs index 9b608cab136dd..e0e175c0dcefe 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/VectorOfTFieldLayoutAlgorithm.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/VectorOfTFieldLayoutAlgorithm.cs @@ -52,7 +52,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp }; } - public unsafe override ComputedStaticFieldLayout ComputeStaticFieldLayout(DefType defType, StaticLayoutKind layoutKind) + public override unsafe ComputedStaticFieldLayout ComputeStaticFieldLayout(DefType defType, StaticLayoutKind layoutKind) { return _fallbackAlgorithm.ComputeStaticFieldLayout(defType, layoutKind); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/VirtualMethodCallHelper.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/VirtualMethodCallHelper.cs index 2261d59239d0f..a9de1fce5e3a5 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/VirtualMethodCallHelper.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/VirtualMethodCallHelper.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using System.Diagnostics; using Internal.TypeSystem; @@ -146,7 +145,7 @@ private static int GetNumberOfBaseSlots(NodeFactory factory, TypeDesc owningType // class Derived : Middle { } // -> Template is Derived<__UniversalCanon> and needs a dictionary slot // // -> Basetype tempalte is Middle<__UniversalCanon, MyStruct>. It's a partial // Universal canonical type, so we need to fully canonicalize it. - // + // // class Middle : Base { } // -> Template is Middle<__UniversalCanon, __UniversalCanon> and needs a dictionary slot // // -> Basetype template is Base<__UniversalCanon> // @@ -193,7 +192,7 @@ public static int GetGenericDictionarySlot(NodeFactory factory, TypeDesc type) public static bool HasGenericDictionarySlot(this TypeDesc type) { // Dictionary slots on generic interfaces are necessary to support static methods on interfaces - // The reason behind making this unconditional is simplicity, and keeping method slot indices for methods on IFoo + // The reason behind making this unconditional is simplicity, and keeping method slot indices for methods on IFoo // and IFoo identical. That won't change. if (type.IsInterface) return type.HasInstantiation; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/WindowsNodeMangler.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/WindowsNodeMangler.cs index 3cbcd19ca3988..ee4117679432f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/WindowsNodeMangler.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/WindowsNodeMangler.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Internal.Text; using Internal.TypeSystem; using System.Diagnostics; @@ -9,7 +8,7 @@ namespace ILCompiler { // // The naming format of these names is known to the debugger - // + // public class WindowsNodeMangler : NodeMangler { public const string NonGCStaticMemberName = "__NONGCSTATICS"; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/XmlObjectDumper.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/XmlObjectDumper.cs index b1fa747348f29..2320aa663617a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/XmlObjectDumper.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/XmlObjectDumper.cs @@ -70,7 +70,7 @@ protected override void DumpObjectNode(NameMangler mangler, ObjectNode node, Obj private string HashData(byte[] data) { - return BitConverter.ToString(_sha256.ComputeHash(data)).Replace("-", "").ToLower(); + return BitConverter.ToString(_sha256.ComputeHash(data)).Replace("-", "").ToLowerInvariant(); } internal override void End() diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs index 9f9c877fbed5d..cb55f2e02feaf 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.TypeSystem; using Internal.ReadyToRunConstants; @@ -16,7 +14,7 @@ namespace Internal.IL { // Implements an IL scanner that scans method bodies to be compiled by the code generation // backend before the actual compilation happens to gain insights into the code. - partial class ILImporter + internal partial class ILImporter { private readonly MethodIL _methodIL; private readonly MethodIL _canonMethodIL; @@ -32,7 +30,7 @@ partial class ILImporter private readonly byte[] _ilBytes; - private class BasicBlock + private sealed class BasicBlock { // Common fields public enum ImportState : byte @@ -57,7 +55,7 @@ public enum ImportState : byte private int _currentInstructionOffset; private int _previousInstructionOffset; - private class ExceptionRegion + private sealed class ExceptionRegion { public ILExceptionRegion ILRegion; } @@ -181,8 +179,8 @@ private ISymbolNode GetHelperEntrypoint(ReadyToRunHelper helper) return _compilation.GetHelperEntrypoint(helper); } - private void MarkInstructionBoundary() { } - private void EndImportingBasicBlock(BasicBlock basicBlock) { } + private static void MarkInstructionBoundary() { } + private static void EndImportingBasicBlock(BasicBlock basicBlock) { } private void StartImportingBasicBlock(BasicBlock basicBlock) { @@ -983,12 +981,12 @@ private void ImportLdToken(int token) } } - private void ImportRefAnyType() + private static void ImportRefAnyType() { // TODO } - private void ImportArgList() + private static void ImportArgList() { } @@ -1228,27 +1226,27 @@ private int ReadILTokenAt(int ilOffset) + (_ilBytes[ilOffset + 3] << 24)); } - private void ReportInvalidBranchTarget(int targetOffset) + private static void ReportInvalidBranchTarget(int targetOffset) { ThrowHelper.ThrowInvalidProgramException(); } - private void ReportFallthroughAtEndOfMethod() + private static void ReportFallthroughAtEndOfMethod() { ThrowHelper.ThrowInvalidProgramException(); } - private void ReportMethodEndInsideInstruction() + private static void ReportMethodEndInsideInstruction() { ThrowHelper.ThrowInvalidProgramException(); } - private void ReportInvalidInstruction(ILOpcode opcode) + private static void ReportInvalidInstruction(ILOpcode opcode) { ThrowHelper.ThrowInvalidProgramException(); } - private bool IsRuntimeHelpersInitializeArrayOrCreateSpan(MethodDesc method) + private static bool IsRuntimeHelpersInitializeArrayOrCreateSpan(MethodDesc method) { if (method.IsIntrinsic) { @@ -1266,7 +1264,7 @@ private bool IsRuntimeHelpersInitializeArrayOrCreateSpan(MethodDesc method) return false; } - private bool IsTypeGetTypeFromHandle(MethodDesc method) + private static bool IsTypeGetTypeFromHandle(MethodDesc method) { if (method.IsIntrinsic && method.Name == "GetTypeFromHandle") { @@ -1280,7 +1278,7 @@ private bool IsTypeGetTypeFromHandle(MethodDesc method) return false; } - private bool IsTypeEquals(MethodDesc method) + private static bool IsTypeEquals(MethodDesc method) { if (method.IsIntrinsic && method.Name == "op_Equality") { @@ -1294,7 +1292,7 @@ private bool IsTypeEquals(MethodDesc method) return false; } - private bool IsActivatorDefaultConstructorOf(MethodDesc method) + private static bool IsActivatorDefaultConstructorOf(MethodDesc method) { if (method.IsIntrinsic && method.Name == "DefaultConstructorOf" && method.Instantiation.Length == 1) { @@ -1308,7 +1306,7 @@ private bool IsActivatorDefaultConstructorOf(MethodDesc method) return false; } - private bool IsActivatorAllocatorOf(MethodDesc method) + private static bool IsActivatorAllocatorOf(MethodDesc method) { if (method.IsIntrinsic && method.Name == "AllocatorOf" && method.Instantiation.Length == 1) { @@ -1322,7 +1320,7 @@ private bool IsActivatorAllocatorOf(MethodDesc method) return false; } - private bool IsEETypePtrOf(MethodDesc method) + private static bool IsEETypePtrOf(MethodDesc method) { if (method.IsIntrinsic && (method.Name == "EETypePtrOf" || method.Name == "Of") && method.Instantiation.Length == 1) { @@ -1342,40 +1340,40 @@ private TypeDesc GetWellKnownType(WellKnownType wellKnownType) return _compilation.TypeSystemContext.GetWellKnownType(wellKnownType); } - private void ImportNop() { } - private void ImportBreak() { } - private void ImportLoadVar(int index, bool argument) { } - private void ImportStoreVar(int index, bool argument) { } - private void ImportAddressOfVar(int index, bool argument) { } - private void ImportDup() { } - private void ImportPop() { } - private void ImportLoadNull() { } - private void ImportReturn() { } - private void ImportLoadInt(long value, StackValueKind kind) { } - private void ImportLoadFloat(double value) { } - private void ImportLoadIndirect(int token) { } - private void ImportLoadIndirect(TypeDesc type) { } - private void ImportStoreIndirect(int token) { } - private void ImportStoreIndirect(TypeDesc type) { } - private void ImportShiftOperation(ILOpcode opcode) { } - private void ImportCompareOperation(ILOpcode opcode) { } - private void ImportConvert(WellKnownType wellKnownType, bool checkOverflow, bool unsigned) { } - private void ImportUnaryOperation(ILOpcode opCode) { } - private void ImportCpOpj(int token) { } - private void ImportCkFinite() { } - private void ImportLocalAlloc() { } - private void ImportEndFilter() { } - private void ImportCpBlk() { } - private void ImportInitBlk() { } - private void ImportRethrow() { } - private void ImportSizeOf(int token) { } - private void ImportUnalignedPrefix(byte alignment) { } - private void ImportVolatilePrefix() { } - private void ImportTailPrefix() { } - private void ImportNoPrefix(byte mask) { } - private void ImportThrow() { } - private void ImportInitObj(int token) { } - private void ImportLoadLength() { } - private void ImportEndFinally() { } + private static void ImportNop() { } + private static void ImportBreak() { } + private static void ImportLoadVar(int index, bool argument) { } + private static void ImportStoreVar(int index, bool argument) { } + private static void ImportAddressOfVar(int index, bool argument) { } + private static void ImportDup() { } + private static void ImportPop() { } + private static void ImportLoadNull() { } + private static void ImportReturn() { } + private static void ImportLoadInt(long value, StackValueKind kind) { } + private static void ImportLoadFloat(double value) { } + private static void ImportLoadIndirect(int token) { } + private static void ImportLoadIndirect(TypeDesc type) { } + private static void ImportStoreIndirect(int token) { } + private static void ImportStoreIndirect(TypeDesc type) { } + private static void ImportShiftOperation(ILOpcode opcode) { } + private static void ImportCompareOperation(ILOpcode opcode) { } + private static void ImportConvert(WellKnownType wellKnownType, bool checkOverflow, bool unsigned) { } + private static void ImportUnaryOperation(ILOpcode opCode) { } + private static void ImportCpOpj(int token) { } + private static void ImportCkFinite() { } + private static void ImportLocalAlloc() { } + private static void ImportEndFilter() { } + private static void ImportCpBlk() { } + private static void ImportInitBlk() { } + private static void ImportRethrow() { } + private static void ImportSizeOf(int token) { } + private static void ImportUnalignedPrefix(byte alignment) { } + private static void ImportVolatilePrefix() { } + private static void ImportTailPrefix() { } + private static void ImportNoPrefix(byte mask) { } + private static void ImportThrow() { } + private static void ImportInitObj(int token) { } + private static void ImportLoadLength() { } + private static void ImportEndFinally() { } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/PInvokeILProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/PInvokeILProvider.cs index 93fb4cc376c07..945284e43abc5 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/PInvokeILProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/PInvokeILProvider.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.TypeSystem; using Internal.IL.Stubs; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/AppContextInitializerMethod.Sorting.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/AppContextInitializerMethod.Sorting.cs index 8222352a9159c..27d6287aef7e7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/AppContextInitializerMethod.Sorting.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/AppContextInitializerMethod.Sorting.cs @@ -7,7 +7,7 @@ namespace Internal.IL.Stubs.StartupCode { - partial class AppContextInitializerMethod + public partial class AppContextInitializerMethod { protected override int ClassCode => 15749517; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/AppContextInitializerMethod.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/AppContextInitializerMethod.cs index ed40a5f6fcc75..92d9eccdaee95 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/AppContextInitializerMethod.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/AppContextInitializerMethod.cs @@ -87,12 +87,9 @@ public override MethodSignature Signature { get { - if (_signature == null) - { - _signature = new MethodSignature(MethodSignatureFlags.Static, 0, + _signature ??= new MethodSignature(MethodSignatureFlags.Static, 0, Context.GetWellKnownType(WellKnownType.Void), TypeDesc.EmptyTypes); - } return _signature; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.Sorting.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.Sorting.cs index be6be0bb39eb7..05d929146c3ac 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.Sorting.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.Sorting.cs @@ -1,16 +1,13 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; - using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; namespace Internal.IL.Stubs.StartupCode { - partial class NativeLibraryStartupMethod + public partial class NativeLibraryStartupMethod { protected override int ClassCode => -304225482; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs index 4240af2427d15..160a06bb441a2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using Internal.TypeSystem; @@ -87,12 +86,9 @@ public override MethodSignature Signature { get { - if (_signature == null) - { - _signature = new MethodSignature(MethodSignatureFlags.Static | MethodSignatureFlags.UnmanagedCallingConvention, 0, + _signature ??= new MethodSignature(MethodSignatureFlags.Static | MethodSignatureFlags.UnmanagedCallingConvention, 0, Context.GetWellKnownType(WellKnownType.Void), - new TypeDesc[0]); - } + System.Array.Empty()); return _signature; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.Sorting.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.Sorting.cs index d33a2de6a007f..59d582451c80a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.Sorting.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.Sorting.cs @@ -1,17 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; - using Internal.TypeSystem; - -using AssemblyName = System.Reflection.AssemblyName; using Debug = System.Diagnostics.Debug; namespace Internal.IL.Stubs.StartupCode { - partial class StartupCodeMainMethod + public partial class StartupCodeMainMethod { protected override int ClassCode => -304225481; @@ -22,7 +17,7 @@ protected override int CompareToImpl(MethodDesc other, TypeSystemComparer compar return 0; } - partial class MainMethodWrapper + private partial class MainMethodWrapper { protected override int ClassCode => -215672259; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs index 1741ffdd61dd7..7d197f85e08d5 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs @@ -5,8 +5,6 @@ using System.Collections.Generic; using Internal.TypeSystem; - -using AssemblyName = System.Reflection.AssemblyName; using Debug = System.Diagnostics.Debug; namespace Internal.IL.Stubs.StartupCode @@ -175,14 +173,11 @@ public override MethodSignature Signature { get { - if (_signature == null) - { - _signature = new MethodSignature(MethodSignatureFlags.Static | MethodSignatureFlags.UnmanagedCallingConvention, 0, + _signature ??= new MethodSignature(MethodSignatureFlags.Static | MethodSignatureFlags.UnmanagedCallingConvention, 0, Context.GetWellKnownType(WellKnownType.Int32), new TypeDesc[2] { Context.GetWellKnownType(WellKnownType.Int32), Context.GetWellKnownType(WellKnownType.IntPtr) }); - } return _signature; } @@ -204,7 +199,7 @@ public override bool IsUnmanagedCallersOnly /// environment without it being fully initialized. (In particular, the unhandled exception experience /// won't be initialized, making this difficult to diagnose.) /// - private partial class MainMethodWrapper : ILStubMethod + private sealed partial class MainMethodWrapper : ILStubMethod { public MainMethodWrapper(TypeDesc owningType, MethodDesc mainMethod) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj index c87928b82911a..314db52057779 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj @@ -16,6 +16,7 @@ Debug;Release;Checked $(NoWarn);CS8524 + true diff --git a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/ComputedStaticDependencyNode.cs b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/ComputedStaticDependencyNode.cs index 224f4182b5b68..8e043a74a3916 100644 --- a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/ComputedStaticDependencyNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/ComputedStaticDependencyNode.cs @@ -3,9 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Diagnostics; namespace ILCompiler.DependencyAnalysisFramework diff --git a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs index d81c5e5c66a72..78d4a64024558 100644 --- a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs +++ b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs @@ -24,9 +24,11 @@ namespace ILCompiler.DependencyAnalysisFramework /// public sealed class DependencyAnalyzer : DependencyAnalyzerBase where MarkStrategy : struct, IDependencyAnalysisMarkStrategy { - private MarkStrategy _marker = new MarkStrategy(); +#pragma warning disable SA1129 // Do not use default value type constructor + private readonly MarkStrategy _marker = new MarkStrategy(); +#pragma warning restore SA1129 // Do not use default value type constructor private DependencyContextType _dependencyContext; - private IComparer> _resultSorter = null; + private IComparer> _resultSorter; private RandomInsertStack> _markStack; private List> _markedNodes = new List>(); @@ -35,12 +37,12 @@ public sealed class DependencyAnalyzer : De private Dictionary>> _deferredStaticDependencies = new Dictionary>>(); private List> _dynamicDependencyInterestingList = new List>(); private List _markedNodesWithDynamicDependencies = new List(); - private bool _newDynamicDependenciesMayHaveAppeared = false; + private bool _newDynamicDependenciesMayHaveAppeared; private Dictionary, HashSet.CombinedDependencyListEntry>> _conditional_dependency_store = new Dictionary, HashSet.CombinedDependencyListEntry>>(); - private bool _markingCompleted = false; + private bool _markingCompleted; - private class RandomInsertStack + private sealed class RandomInsertStack { private List _nodes = new List(); private readonly Random _randomizer; @@ -115,7 +117,7 @@ public DependencyAnalyzer(DependencyContextType dependencyContext, IComparer /// Add a root node /// - public override sealed void AddRoot(DependencyNodeCore rootNode, string reason) + public sealed override void AddRoot(DependencyNodeCore rootNode, string reason) { if (AddToMarkStack(rootNode, reason, null, null)) { @@ -123,7 +125,7 @@ public override sealed void AddRoot(DependencyNodeCore ro } } - public override sealed ImmutableArray> MarkedNodeList + public sealed override ImmutableArray> MarkedNodeList { get { @@ -136,11 +138,11 @@ public override sealed ImmutableArray> } } - public override sealed event Action> NewMarkedNode; + public sealed override event Action> NewMarkedNode; - public override sealed event Action>> ComputeDependencyRoutine; + public sealed override event Action>> ComputeDependencyRoutine; - public override sealed event Action ComputingDependencyPhaseChange; + public sealed override event Action ComputingDependencyPhaseChange; private IEnumerable> MarkedNodesEnumerable() { @@ -150,7 +152,7 @@ private IEnumerable> MarkedNodesEnumer return _markedNodes; } - public override sealed void VisitLogNodes(IDependencyAnalyzerLogNodeVisitor logNodeVisitor) + public sealed override void VisitLogNodes(IDependencyAnalyzerLogNodeVisitor logNodeVisitor) { foreach (DependencyNodeCore node in MarkedNodesEnumerable()) { @@ -159,7 +161,7 @@ public override sealed void VisitLogNodes(IDependencyAnalyzerLogNodeVisitor logEdgeVisitor) + public sealed override void VisitLogEdges(IDependencyAnalyzerLogEdgeVisitor logEdgeVisitor) { _marker.VisitLogEdges(MarkedNodesEnumerable(), logEdgeVisitor); } @@ -171,8 +173,7 @@ public override sealed void VisitLogEdges(IDependencyAnalyzerLogEdgeVisitorList of nodes which must have static dependencies computed private void ComputeDependencies(List> deferredStaticDependencies) { - if (ComputeDependencyRoutine != null) - ComputeDependencyRoutine(deferredStaticDependencies); + ComputeDependencyRoutine?.Invoke(deferredStaticDependencies); } // Internal details @@ -197,7 +198,7 @@ private void GetStaticDependenciesImpl(DependencyNodeCore } else { - HashSet.CombinedDependencyListEntry> storedDependencySet = null; + HashSet.CombinedDependencyListEntry> storedDependencySet; if (!_conditional_dependency_store.TryGetValue(dependency.OtherReasonNode, out storedDependencySet)) { storedDependencySet = new HashSet.CombinedDependencyListEntry>(); @@ -212,7 +213,7 @@ private void GetStaticDependenciesImpl(DependencyNodeCore } } - int _currentDependencyPhase = 0; + private int _currentDependencyPhase; private void GetStaticDependencies(DependencyNodeCore node) { @@ -264,7 +265,7 @@ private void ProcessMarkStack() // If this new node satisfies any stored conditional dependencies, // add them to the mark stack - HashSet.CombinedDependencyListEntry> storedDependencySet = null; + HashSet.CombinedDependencyListEntry> storedDependencySet; if (_conditional_dependency_store.TryGetValue(currentNode, out storedDependencySet)) { foreach (DependencyNodeCore.CombinedDependencyListEntry newlySatisfiedDependency in storedDependencySet) @@ -336,8 +337,7 @@ public override void ComputeMarkedNodes() _currentDependencyPhase++; // 3. Notify that new dependency phase has been entered - if (ComputingDependencyPhaseChange != null) - ComputingDependencyPhaseChange(_currentDependencyPhase); + ComputingDependencyPhaseChange?.Invoke(_currentDependencyPhase); } } while ((_markStack.Count != 0) || (_deferredStaticDependencies.Count != 0)); @@ -362,8 +362,7 @@ private bool AddToMarkStack(DependencyNodeCore node, stri node.CallOnMarked(_dependencyContext); - if (NewMarkedNode != null) - NewMarkedNode(node); + NewMarkedNode?.Invoke(node); return true; } diff --git a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzerBase.cs b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzerBase.cs index d4ee7616c3183..38d3e7c702358 100644 --- a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzerBase.cs +++ b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzerBase.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; -using System.IO; namespace ILCompiler.DependencyAnalysisFramework { @@ -14,12 +13,12 @@ namespace ILCompiler.DependencyAnalysisFramework /// so that if MarkedNodeList is called, it can produce the complete graph. For the case /// where nodes have deferred computation the ComputeDependencyRoutine even will be triggered /// to fill in data. - /// - /// The Log visitor logic can be called at any time, and should log the current set of marked + /// + /// The Log visitor logic can be called at any time, and should log the current set of marked /// nodes and edges in the analysis. (Notably, if its called before MarkedNodeList is evaluated /// it will contain only roots, if its called during, the edges/nodes may be incomplete, and /// if called after MarkedNodeList is computed it will be a complete graph. - /// + /// /// /// public abstract class DependencyAnalyzerBase diff --git a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyNode.cs b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyNode.cs index fdee41a043e8d..d8913b8022c48 100644 --- a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyNode.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Diagnostics; namespace ILCompiler.DependencyAnalysisFramework @@ -36,7 +35,7 @@ public bool Marked public sealed override bool Equals(object obj) { - return Object.ReferenceEquals(this, obj); + return ReferenceEquals(this, obj); } public sealed override int GetHashCode() diff --git a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyNodeCore.cs b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyNodeCore.cs index 3ef331e3698c4..3f50135eeb868 100644 --- a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyNodeCore.cs +++ b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyNodeCore.cs @@ -3,9 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace ILCompiler.DependencyAnalysisFramework { @@ -98,9 +95,9 @@ public override int GetHashCode() public bool Equals(CombinedDependencyListEntry other) { - return Object.ReferenceEquals(Node, other.Node) - && Object.ReferenceEquals(OtherReasonNode, other.OtherReasonNode) - && Object.Equals(Reason, other.Reason); + return ReferenceEquals(Node, other.Node) + && ReferenceEquals(OtherReasonNode, other.OtherReasonNode) + && Equals(Reason, other.Reason); } } @@ -124,7 +121,7 @@ public abstract bool StaticDependenciesAreComputed get; } - public virtual int DependencyPhaseForDeferredStaticComputation { get; } = 0; + public virtual int DependencyPhaseForDeferredStaticComputation { get; } public abstract IEnumerable GetStaticDependencies(DependencyContextType context); diff --git a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DgmlWriter.cs b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DgmlWriter.cs index a1c1dbe57d548..a6018ed51056b 100644 --- a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DgmlWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DgmlWriter.cs @@ -17,10 +17,10 @@ public static void WriteDependencyGraphToStream(Stream st } } - internal class DgmlWriter : IDisposable, IDependencyAnalyzerLogEdgeVisitor, IDependencyAnalyzerLogNodeVisitor + internal sealed class DgmlWriter : IDisposable, IDependencyAnalyzerLogEdgeVisitor, IDependencyAnalyzerLogNodeVisitor { private XmlWriter _xmlWrite; - private bool _done = false; + private bool _done; private DependencyContextType _context; public DgmlWriter(XmlWriter xmlWrite, DependencyContextType context) @@ -101,7 +101,7 @@ void IDisposable.Dispose() } private Dictionary _nodeMappings = new Dictionary(); - private int _nodeNextId = 0; + private int _nodeNextId; private void AddNode(DependencyNodeCore node) { diff --git a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/EventSourceLogStrategy.cs b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/EventSourceLogStrategy.cs index e7615ad545fbf..a5f70a0fa0bcf 100644 --- a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/EventSourceLogStrategy.cs +++ b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/EventSourceLogStrategy.cs @@ -1,13 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Diagnostics.CodeAnalysis; using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Threading; using System.Diagnostics.Tracing; using System.Runtime.InteropServices; @@ -15,18 +10,18 @@ namespace ILCompiler.DependencyAnalysisFramework { [EventSource(Name = "Microsoft-ILCompiler-DependencyGraph")] - class GraphEventSource : EventSource + internal sealed class GraphEventSource : EventSource { - public class Keywords + public static class Keywords { public const EventKeywords Graph = (EventKeywords)1; } - // Notice that the bodies of the events follow a pattern: WriteEvent(ID, ) where + // Notice that the bodies of the events follow a pattern: WriteEvent(ID, ) where // ID is a unique ID starting at 1 and incrementing for each new event method. and - // is every argument for the method. + // is every argument for the method. // WriteEvent then takes care of all the details of actually writing out the values complete - // with the name of the event (method name) as well as the names and types of all the parameters. + // with the name of the event (method name) as well as the names and types of all the parameters. [Event(1, Keywords = Keywords.Graph, Level = EventLevel.Informational)] public void Graph(int id, string name) { WriteEvent(1, id, name); } [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", @@ -42,13 +37,13 @@ public class Keywords [Event(4, Keywords = Keywords.Graph, Level = EventLevel.Informational)] public void ConditionalEdge(int id, int dependentIndex1, int dependentIndex2, int dependencyIndex, string reason) { WriteEvent(4, id, dependentIndex1, dependentIndex2, dependencyIndex, reason); } - // Typically you only create one EventSource and use it throughout your program. Thus a static field makes sense. + // Typically you only create one EventSource and use it throughout your program. Thus a static field makes sense. public static GraphEventSource Log = new GraphEventSource(); } public struct EventSourceLogStrategy : IDependencyAnalysisMarkStrategy { - private static int s_GraphIds = 0; + private static int s_GraphIds; private int GraphId; private int RootIndex; @@ -59,7 +54,7 @@ public static bool IsEventSourceEnabled { get { - return + return #if !ALWAYS_SUPPORT_EVENTSOURCE_LOG RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && // Processing these event source events is only implemented on Windows #endif diff --git a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/FirstMarkLogStrategy.cs b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/FirstMarkLogStrategy.cs index 3d1c439dd4010..655fb43a35c1c 100644 --- a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/FirstMarkLogStrategy.cs +++ b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/FirstMarkLogStrategy.cs @@ -3,18 +3,13 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Xml; -using System.IO; using System.Diagnostics; namespace ILCompiler.DependencyAnalysisFramework { public struct FirstMarkLogStrategy : IDependencyAnalysisMarkStrategy { - private class MarkData + private sealed class MarkData { public MarkData(string reason, DependencyNodeCore reason1, DependencyNodeCore reason2) { @@ -53,8 +48,7 @@ bool IDependencyAnalysisMarkStrategy.MarkNode( if ((reasonNode == null) && (reasonNode2 == null)) { Debug.Assert(reason != null); - if (_reasonStringOnlyNodes == null) - _reasonStringOnlyNodes = new HashSet(); + _reasonStringOnlyNodes ??= new HashSet(); _reasonStringOnlyNodes.Add(reason); } diff --git a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/FullGraphLogStrategy.cs b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/FullGraphLogStrategy.cs index 421ee4fd314b3..4847782fd3f78 100644 --- a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/FullGraphLogStrategy.cs +++ b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/FullGraphLogStrategy.cs @@ -3,11 +3,6 @@ using System; using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Xml; using System.Diagnostics; namespace ILCompiler.DependencyAnalysisFramework @@ -124,8 +119,7 @@ bool IDependencyAnalysisMarkStrategy.MarkNode( if ((reasonNode == null) && (reasonNode2 == null)) { Debug.Assert(reason != null); - if (_reasonStringOnlyNodes == null) - _reasonStringOnlyNodes = new HashSet(); + _reasonStringOnlyNodes ??= new HashSet(); _reasonStringOnlyNodes.Add(reason); } diff --git a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/IDependencyAnalysisMarkStrategy.cs b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/IDependencyAnalysisMarkStrategy.cs index 61faf7e624ad4..23b4384ea6467 100644 --- a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/IDependencyAnalysisMarkStrategy.cs +++ b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/IDependencyAnalysisMarkStrategy.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; namespace ILCompiler.DependencyAnalysisFramework diff --git a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/IDependencyAnalyzerLogEdgeVisitor.cs b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/IDependencyAnalyzerLogEdgeVisitor.cs index 422471119d96d..4c55ba328b4e0 100644 --- a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/IDependencyAnalyzerLogEdgeVisitor.cs +++ b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/IDependencyAnalyzerLogEdgeVisitor.cs @@ -1,12 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace ILCompiler.DependencyAnalysisFramework { public interface IDependencyAnalyzerLogEdgeVisitor diff --git a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/IDependencyNode.cs b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/IDependencyNode.cs index 6ae00bd7eec7d..76365d9c68bc5 100644 --- a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/IDependencyNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/IDependencyNode.cs @@ -36,7 +36,7 @@ bool StaticDependenciesAreComputed } IEnumerable.DependencyListEntry> GetStaticDependencies(DependencyContextType context); - + IEnumerable.CombinedDependencyListEntry> GetConditionalStaticDependencies(DependencyContextType context); IEnumerable.CombinedDependencyListEntry> SearchDynamicDependencies(List> markedNodes, int firstNode, DependencyContextType context); diff --git a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/ILCompiler.DependencyAnalysisFramework.csproj b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/ILCompiler.DependencyAnalysisFramework.csproj index 28aa33b5afe73..2df31ad2b810c 100644 --- a/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/ILCompiler.DependencyAnalysisFramework.csproj +++ b/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/ILCompiler.DependencyAnalysisFramework.csproj @@ -8,6 +8,7 @@ x64;x86 AnyCPU false + true false Debug;Release;Checked + true diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs index b29b104f41d70..efc9c60ac8cc0 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs @@ -23,7 +23,7 @@ namespace Internal.JitInterface { - unsafe partial class CorInfoImpl + internal unsafe partial class CorInfoImpl { private const CORINFO_RUNTIME_ABI TargetABI = CORINFO_RUNTIME_ABI.CORINFO_NATIVEAOT_ABI; @@ -55,8 +55,7 @@ public void CompileMethod(MethodCodeNode methodCodeNodeNeedingCode, MethodIL met _methodCodeNode = methodCodeNodeNeedingCode; _isFallbackBodyCompilation = methodIL != null; - if (methodIL == null) - methodIL = _compilation.GetMethodIL(MethodBeingCompiled); + methodIL ??= _compilation.GetMethodIL(MethodBeingCompiled); try { @@ -94,7 +93,7 @@ private enum CFI_OPCODE // - Combine in one single block for the whole prolog instead of one CFI block per assembler instruction // - Store CFA definition first // - Store all used registers in ascending order - private byte[] CompressARM64CFI(byte[] blobData) + private static byte[] CompressARM64CFI(byte[] blobData) { if (blobData == null || blobData.Length == 0) { @@ -223,7 +222,7 @@ private byte[] CompressARM64CFI(byte[] blobData) } } - private CORINFO_RUNTIME_LOOKUP_KIND GetLookupKindFromContextSource(GenericContextSource contextSource) + private static CORINFO_RUNTIME_LOOKUP_KIND GetLookupKindFromContextSource(GenericContextSource contextSource) { switch (contextSource) { @@ -825,7 +824,7 @@ private InfoAccessType constructStringLiteral(CORINFO_MODULE_STRUCT_* module, md return stringObject.RepresentsIndirectionCell ? InfoAccessType.IAT_PVALUE : InfoAccessType.IAT_VALUE; } - enum RhEHClauseKind + private enum RhEHClauseKind { RH_EH_CLAUSE_TYPED = 0, RH_EH_CLAUSE_FAULT = 1, @@ -834,7 +833,7 @@ enum RhEHClauseKind private ObjectNode.ObjectData EncodeEHInfo() { - var builder = new ObjectDataBuilder(); + var builder = default(ObjectDataBuilder); builder.RequireInitialAlignment(1); int totalClauses = _ehClauses.Length; @@ -950,7 +949,7 @@ private void setVars(CORINFO_METHOD_STRUCT_* ftn, uint cVars, NativeVarInfo* var debugVarInfoBuilders[varNumber].Add(new DebugVarRangeInfo(vars[i].startOffset, vars[i].endOffset, vars[i].varLoc)); } - var debugVarInfos = new ArrayBuilder(); + var debugVarInfos = default(ArrayBuilder); for (uint i = 0; i < debugVarInfoBuilders.Length; i++) { if (debugVarInfoBuilders[i].Count > 0) @@ -984,7 +983,7 @@ private void setBoundaries(CORINFO_METHOD_STRUCT_* ftn, uint cMap, OffsetMapping } } - ArrayBuilder debugLocInfos = new ArrayBuilder(); + ArrayBuilder debugLocInfos = default(ArrayBuilder); for (int i = 0; i < cMap; i++) { OffsetMapping* nativeToILInfo = &pMap[i]; @@ -1554,12 +1553,14 @@ private void getCallInfo(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_RESO { pResult->codePointerOrStubLookup.lookupKind.needsRuntimeLookup = false; pResult->codePointerOrStubLookup.constLookup.accessType = InfoAccessType.IAT_PVALUE; +#pragma warning disable SA1001, SA1113, SA1115 // Commas should be spaced correctly pResult->codePointerOrStubLookup.constLookup.addr = (void*)ObjectToHandle( _compilation.NodeFactory.InterfaceDispatchCell(targetMethod #if !SUPPORT_JIT , _compilation.NameMangler.GetMangledMethodName(MethodBeingCompiled).ToString() #endif )); +#pragma warning restore SA1001, SA1113, SA1115 // Commas should be spaced correctly } pResult->nullInstanceCheck = false; @@ -1862,7 +1863,9 @@ private unsafe HRESULT allocPgoInstrumentationBySchema(CORINFO_METHOD_STRUCT_* f throw new NotImplementedException("allocPgoInstrumentationBySchema"); } +#pragma warning disable CA1822 // Mark members as static private CORINFO_CLASS_STRUCT_* getLikelyClass(CORINFO_METHOD_STRUCT_* ftnHnd, CORINFO_CLASS_STRUCT_* baseHnd, uint IlOffset, ref uint pLikelihood, ref uint pNumberOfClasses) +#pragma warning restore CA1822 // Mark members as static { return null; } @@ -1980,7 +1983,9 @@ private int SizeOfPInvokeTransitionFrame private bool canGetCookieForPInvokeCalliSig(CORINFO_SIG_INFO* szMetaSig) { throw new NotImplementedException("canGetCookieForPInvokeCalliSig"); } +#pragma warning disable CA1822 // Mark members as static private void classMustBeLoadedBeforeCodeIsRun(CORINFO_CLASS_STRUCT_* cls) +#pragma warning restore CA1822 // Mark members as static { } @@ -1994,15 +1999,21 @@ private void setEHinfo(uint EHnumber, ref CORINFO_EH_CLAUSE clause) _ehClauses[EHnumber] = clause; } +#pragma warning disable CA1822 // Mark members as static private void beginInlining(CORINFO_METHOD_STRUCT_* inlinerHnd, CORINFO_METHOD_STRUCT_* inlineeHnd) +#pragma warning restore CA1822 // Mark members as static { } +#pragma warning disable CA1822 // Mark members as static private void reportInliningDecision(CORINFO_METHOD_STRUCT_* inlinerHnd, CORINFO_METHOD_STRUCT_* inlineeHnd, CorInfoInline inlineResult, byte* reason) +#pragma warning restore CA1822 // Mark members as static { } +#pragma warning disable CA1822 // Mark members as static private void updateEntryPointForTailCall(ref CORINFO_CONST_LOOKUP entryPoint) +#pragma warning restore CA1822 // Mark members as static { } diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ArchitectureSpecificFieldLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ArchitectureSpecificFieldLayoutTests.cs index f9fe3b7687439..b474694a91579 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ArchitectureSpecificFieldLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ArchitectureSpecificFieldLayoutTests.cs @@ -2,11 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Internal.TypeSystem.Ecma; using Internal.TypeSystem; using Xunit; diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CanonicalizationTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CanonicalizationTests.cs index d3f2c6c6036d6..c42cacbe3bfe4 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CanonicalizationTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CanonicalizationTests.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - using Internal.TypeSystem; using Xunit; diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CastingTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CastingTests.cs index 4bcf3432f522f..7ba6109f6405a 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CastingTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CastingTests.cs @@ -54,7 +54,7 @@ public void TestInterfaceCasting() Assert.False(objectType.CanCastTo(iFooType)); } - + [Fact] public void TestSameSizeArrayTypeCasting() { diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ConstraintsValidationTest.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ConstraintsValidationTest.cs index 3ea1408a96c10..a263233a5eef5 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ConstraintsValidationTest.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ConstraintsValidationTest.cs @@ -44,7 +44,7 @@ public ConstraintsValidationTest() _context = new TestTypeSystemContext(TargetArchitecture.Unknown); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); - + _testModule = systemModule; _iNonGenType = _testModule.GetType("GenericConstraints", "INonGen"); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ExceptionStringTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ExceptionStringTests.cs index d40bdf774126d..776dc296442af 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ExceptionStringTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ExceptionStringTests.cs @@ -23,4 +23,4 @@ public void TestAllExceptionIdsHaveMessages() } } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ILCompiler.TypeSystem.Tests.csproj b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ILCompiler.TypeSystem.Tests.csproj index 1f6b33ff18ba3..6d58717c7cbba 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ILCompiler.TypeSystem.Tests.csproj +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ILCompiler.TypeSystem.Tests.csproj @@ -17,6 +17,7 @@ READYTORUN;$(DefineConstants) + true diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InterfacesTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InterfacesTests.cs index 8e6d96f2cffd6..8cbadda3948f1 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InterfacesTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InterfacesTests.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Linq; using Internal.TypeSystem; diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/RuntimeDeterminedTypesTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/RuntimeDeterminedTypesTests.cs index a394a562af9f5..210df8937bfe9 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/RuntimeDeterminedTypesTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/RuntimeDeterminedTypesTests.cs @@ -26,7 +26,7 @@ public RuntimeDeterminedTypesTests() _context = new TestTypeSystemContext(TargetArchitecture.Unknown); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); - + _testModule = systemModule; _referenceType = _testModule.GetType("Canonicalization", "ReferenceType"); @@ -140,7 +140,7 @@ public void TestSignatureInstantiation() var grtOverRtStRtShared = grtOverRtStRt.ConvertToSharedRuntimeDeterminedForm(); // GenericReferenceTypeWithThreeParams substituted over - // an instantiation of is + // an instantiation of is // GenericReferenceTypeWithThreeParams var grtOverRtStRtSharedInstantiated = grtOverRtStRtShared.GetNonRuntimeDeterminedTypeFromRuntimeDeterminedSubtypeViaSubstitution( new Instantiation(_referenceType, _structType, _otherReferenceType), diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs index 23e1a9f58cfe2..767f7d760d4a8 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs @@ -6,9 +6,6 @@ using System.Linq; using System.Text; -using System.Reflection.Metadata; -using System.Reflection.Metadata.Ecma335; - using Internal.IL; using Internal.TypeSystem; using Internal.TypeSystem.Ecma; @@ -253,7 +250,7 @@ public void TestMDArrayFunctionReading() { successes++; } - _output.WriteLine($"call {tokenReferenceResult.ToString()}"); + _output.WriteLine($"call {tokenReferenceResult}"); break; } } diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.DiagnosticName.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.DiagnosticName.cs index 0ffbdd8a4c0a0..3c6496f2a3090 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.DiagnosticName.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.DiagnosticName.cs @@ -1,14 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; -using System.Linq; - using Internal.TypeSystem; -using Xunit; - namespace TypeSystemTests { diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TestMetadataFieldLayoutAlgorithm.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TestMetadataFieldLayoutAlgorithm.cs index fdd8382a5bdcf..8e7b749fa274f 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TestMetadataFieldLayoutAlgorithm.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TestMetadataFieldLayoutAlgorithm.cs @@ -1,9 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; - using Internal.TypeSystem; namespace TypeSystemTests diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TestTypeSystemContext.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TestTypeSystemContext.cs index 3f963c24104eb..83cc977d22945 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TestTypeSystemContext.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TestTypeSystemContext.cs @@ -19,18 +19,18 @@ public enum CanonicalizationMode RuntimeDetermined, } - class TestTypeSystemContext : MetadataTypeSystemContext + internal class TestTypeSystemContext : MetadataTypeSystemContext { - Dictionary _modules = new Dictionary(StringComparer.OrdinalIgnoreCase); + private Dictionary _modules = new Dictionary(StringComparer.OrdinalIgnoreCase); private VectorFieldLayoutAlgorithm _vectorFieldLayoutAlgorithm; private Int128FieldLayoutAlgorithm _int128FieldLayoutAlgorithm; - MetadataFieldLayoutAlgorithm _metadataFieldLayout = new TestMetadataFieldLayoutAlgorithm(); - MetadataRuntimeInterfacesAlgorithm _metadataRuntimeInterfacesAlgorithm = new MetadataRuntimeInterfacesAlgorithm(); - ArrayOfTRuntimeInterfacesAlgorithm _arrayOfTRuntimeInterfacesAlgorithm; - VirtualMethodAlgorithm _virtualMethodAlgorithm = new MetadataVirtualMethodAlgorithm(); - + private MetadataFieldLayoutAlgorithm _metadataFieldLayout = new TestMetadataFieldLayoutAlgorithm(); + private MetadataRuntimeInterfacesAlgorithm _metadataRuntimeInterfacesAlgorithm = new MetadataRuntimeInterfacesAlgorithm(); + private ArrayOfTRuntimeInterfacesAlgorithm _arrayOfTRuntimeInterfacesAlgorithm; + private VirtualMethodAlgorithm _virtualMethodAlgorithm = new MetadataVirtualMethodAlgorithm(); + public CanonicalizationMode CanonMode { get; set; } = CanonicalizationMode.RuntimeDetermined; public TestTypeSystemContext(TargetArchitecture arch, TargetOS targetOS = TargetOS.Unknown) @@ -54,10 +54,7 @@ public ModuleDesc CreateModuleForSimpleName(string simpleName, Stream preLoadedF string bindingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string filePath = Path.Combine(bindingDirectory, simpleName + ".dll"); Stream peStream = preLoadedFile; - if (peStream == null) - { - peStream = File.OpenRead(filePath); - } + peStream ??= File.OpenRead(filePath); ModuleDesc module = Internal.TypeSystem.Ecma.EcmaModule.Create(this, new PEReader(peStream), containingAssembly: null); _modules.Add(simpleName, module); @@ -87,10 +84,7 @@ public override FieldLayoutAlgorithm GetLayoutAlgorithmForType(DefType type) protected override RuntimeInterfacesAlgorithm GetRuntimeInterfacesAlgorithmForNonPointerArrayType(ArrayType type) { - if (_arrayOfTRuntimeInterfacesAlgorithm == null) - { - _arrayOfTRuntimeInterfacesAlgorithm = new ArrayOfTRuntimeInterfacesAlgorithm(SystemModule.GetType("System", "Array`1")); - } + _arrayOfTRuntimeInterfacesAlgorithm ??= new ArrayOfTRuntimeInterfacesAlgorithm(SystemModule.GetType("System", "Array`1")); return _arrayOfTRuntimeInterfacesAlgorithm; } diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeNameParsingTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeNameParsingTests.cs index d7a08bf583d50..c4549db3d9473 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeNameParsingTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeNameParsingTests.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using Internal.TypeSystem; @@ -164,21 +163,21 @@ public void TestInstantiatedTypes() _simpleType, _context.GetWellKnownType(WellKnownType.Int32) ); - TypeDesc result = _testModule.GetTypeByCustomAttributeTypeName(String.Format( + TypeDesc result = _testModule.GetTypeByCustomAttributeTypeName(string.Format( "TypeNameParsing.VeryGeneric`3[[System.Object, {0}],TypeNameParsing.Simple,[System.Int32, {0}]]", _coreAssemblyQualifier)); Assert.Equal(expected, result); } { TypeDesc expected = nullableType.MakeInstantiatedType(_structType); - TypeDesc result = _testModule.GetTypeByCustomAttributeTypeName(String.Format( + TypeDesc result = _testModule.GetTypeByCustomAttributeTypeName(string.Format( "System.Nullable`1[TypeNameParsing.Struct], {0}", _coreAssemblyQualifier)); Assert.Equal(expected, result); } { TypeDesc expected = nullableType.MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32)); - TypeDesc result = _testModule.GetTypeByCustomAttributeTypeName(String.Format( + TypeDesc result = _testModule.GetTypeByCustomAttributeTypeName(string.Format( "System.Nullable`1[[System.Int32, {0}]], {0}", _coreAssemblyQualifier)); Assert.Equal(expected, result); } @@ -205,7 +204,7 @@ public void TestMixed() TypeDesc expected = _nestedNongenericType.MakeInstantiatedType( nullableType.MakeInstantiatedType(_structType) ); - TypeDesc result = _testModule.GetTypeByCustomAttributeTypeName(String.Format( + TypeDesc result = _testModule.GetTypeByCustomAttributeTypeName(string.Format( "TypeNameParsing.Generic`1+NestedNongeneric[[System.Nullable`1[TypeNameParsing.Struct], {0}]]", _coreAssemblyQualifier)); Assert.Equal(expected, result); } @@ -215,7 +214,7 @@ public void TestMixed() nullableType.MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32)), _nestedType.MakeArrayType() ); - TypeDesc result = _testModule.GetTypeByCustomAttributeTypeName(String.Format( + TypeDesc result = _testModule.GetTypeByCustomAttributeTypeName(string.Format( "TypeNameParsing.Generic`1+NestedGeneric`1[[System.Nullable`1[[System.Int32, {0}]], {0}],TypeNameParsing.Simple+Nested[]]", _coreAssemblyQualifier)); Assert.Equal(expected, result); } diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/UniversalGenericFieldLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/UniversalGenericFieldLayoutTests.cs index 6b81314b9f976..2e42e7bac0d46 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/UniversalGenericFieldLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/UniversalGenericFieldLayoutTests.cs @@ -68,7 +68,7 @@ public void LayoutIntTests() Assert.Equal(0, new LayoutInt(0).AsInt); Assert.Equal(1, new LayoutInt(1).AsInt); - Assert.Equal(Int32.MaxValue, new LayoutInt(Int32.MaxValue).AsInt); + Assert.Equal(int.MaxValue, new LayoutInt(int.MaxValue).AsInt); Assert.Throws(() => { return LayoutInt.Indeterminate.AsInt; }); Assert.Equal(LayoutInt.Indeterminate, LayoutInt.Indeterminate + LayoutInt.Indeterminate); @@ -209,7 +209,7 @@ public void TestLayoutIntAlignUp(TargetDetails target) } - private void TestLayoutOfUniversalCanonTypeOnArchitecture(TypeSystemContext context) + private static void TestLayoutOfUniversalCanonTypeOnArchitecture(TypeSystemContext context) { // Assert all of the various layout information about the universal canon type itself Assert.Equal(LayoutInt.Indeterminate, context.UniversalCanonType.InstanceFieldAlignment); @@ -289,7 +289,7 @@ public void TestAllFieldsStructUniversalGeneric() Assert.Equal(LayoutInt.Indeterminate, genOfUUU.GetFields().ElementAt(2).Offset); } - private void TestIndeterminatedNestedStructFieldPerContext(TypeSystemContext context, ModuleDesc testModule, out InstantiatedType genOfIntNestedInt, out InstantiatedType genOfLongNestedInt) + private static void TestIndeterminatedNestedStructFieldPerContext(TypeSystemContext context, ModuleDesc testModule, out InstantiatedType genOfIntNestedInt, out InstantiatedType genOfLongNestedInt) { // Given a struct with all field universal, what is the layout? MetadataType tGen = testModule.GetType("GenericTypes", "GenStruct`3"); @@ -338,7 +338,7 @@ public void TestIndeterminateNestedStructField() Assert.Equal(LayoutInt.Indeterminate, genOfLongNestedInt.InstanceByteAlignment); } - private void AssertClassIndeterminateSize(TypeSystemContext context, MetadataType type, LayoutInt expectedIndeterminateByteAlignment) + private static void AssertClassIndeterminateSize(TypeSystemContext context, MetadataType type, LayoutInt expectedIndeterminateByteAlignment) { Assert.Equal(context.Target.LayoutPointerSize, type.InstanceFieldAlignment); Assert.Equal(context.Target.LayoutPointerSize, type.InstanceFieldSize); @@ -347,7 +347,7 @@ private void AssertClassIndeterminateSize(TypeSystemContext context, MetadataTyp Assert.Equal(LayoutInt.Indeterminate, type.InstanceByteCountUnaligned); } - private void CommonClassLayoutTestBits(ModuleDesc testModule, + private void CommonClassLayoutTestBits(ModuleDesc testModule, TypeSystemContext context, LayoutInt expectedIndeterminateByteAlignment, out InstantiatedType genOfIU, diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ValueTypeShapeCharacteristicsTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ValueTypeShapeCharacteristicsTests.cs index 2971fd468ead3..64ffa38b96353 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ValueTypeShapeCharacteristicsTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ValueTypeShapeCharacteristicsTests.cs @@ -32,7 +32,7 @@ public void TestHfaPrimitives() Assert.True(singleType.IsHomogeneousAggregate); Assert.Equal(Float32Aggregate, singleType.ValueTypeShapeCharacteristics); - + Assert.True(doubleType.IsHomogeneousAggregate); Assert.Equal(Float64Aggregate, doubleType.ValueTypeShapeCharacteristics); } diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs index 938377d8cd3c9..1053335237379 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs @@ -77,7 +77,7 @@ public void TestVirtualDispatchOnGenericType() MethodDesc targetOnInstance = testInstance.GetMethod("ToString", toStringSig); MethodDesc targetMethod = testInstance.FindVirtualFunctionTargetMethodOnObjectType(objectToString); - Assert.Equal(targetOnInstance, targetMethod); + Assert.Equal(targetOnInstance, targetMethod); } [Fact] diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj b/src/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj index 4108ff822ed7f..5fa3238e45d0a 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj @@ -18,6 +18,7 @@ false Debug;Release;Checked true + true diff --git a/src/coreclr/tools/aot/ILCompiler/ConfigurablePInvokePolicy.cs b/src/coreclr/tools/aot/ILCompiler/ConfigurablePInvokePolicy.cs index 93fd389484b60..f5f634c06f12d 100644 --- a/src/coreclr/tools/aot/ILCompiler/ConfigurablePInvokePolicy.cs +++ b/src/coreclr/tools/aot/ILCompiler/ConfigurablePInvokePolicy.cs @@ -11,7 +11,7 @@ namespace ILCompiler { - class ConfigurablePInvokePolicy : PInvokeILEmitterConfiguration + internal sealed class ConfigurablePInvokePolicy : PInvokeILEmitterConfiguration { private readonly TargetDetails _target; private readonly Dictionary> _directPInvokes; diff --git a/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj b/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj index 0f53c52bca6bb..3c2f916dffc61 100644 --- a/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj @@ -1,7 +1,8 @@ - + $(RuntimeBinDir)ilc/ $(OutputRid) + true diff --git a/src/coreclr/tools/aot/ILCompiler/Program.cs b/src/coreclr/tools/aot/ILCompiler/Program.cs index f3c064835d8bf..7adb06231ed9a 100644 --- a/src/coreclr/tools/aot/ILCompiler/Program.cs +++ b/src/coreclr/tools/aot/ILCompiler/Program.cs @@ -23,7 +23,7 @@ namespace ILCompiler { - internal class Program + internal sealed class Program { private const string DefaultSystemModule = "System.Private.CoreLib"; @@ -116,7 +116,7 @@ private Program() { } - private void Help(string helpText) + private static void Help(string helpText) { Console.WriteLine(); Console.Write(".NET Native IL Compiler"); @@ -276,13 +276,13 @@ private ArgumentSyntax ParseCommandLine(string[] args) string[] ValidArchitectures = new string[] { "arm", "arm64", "x86", "x64" }; string[] ValidOS = new string[] { "windows", "linux", "osx" }; - Program.ComputeDefaultOptions(out TargetOS defaultOs, out TargetArchitecture defaultArch); + ComputeDefaultOptions(out TargetOS defaultOs, out TargetArchitecture defaultArch); - extraHelp.Add(String.Format("Valid switches for {0} are: '{1}'. The default value is '{2}'", "--targetos", String.Join("', '", ValidOS), defaultOs.ToString().ToLowerInvariant())); + extraHelp.Add(string.Format("Valid switches for {0} are: '{1}'. The default value is '{2}'", "--targetos", string.Join("', '", ValidOS), defaultOs.ToString().ToLowerInvariant())); extraHelp.Add(""); - extraHelp.Add(String.Format("Valid switches for {0} are: '{1}'. The default value is '{2}'", "--targetarch", String.Join("', '", ValidArchitectures), defaultArch.ToString().ToLowerInvariant())); + extraHelp.Add(string.Format("Valid switches for {0} are: '{1}'. The default value is '{2}'", "--targetarch", string.Join("', '", ValidArchitectures), defaultArch.ToString().ToLowerInvariant())); extraHelp.Add(""); @@ -296,7 +296,7 @@ private ArgumentSyntax ParseCommandLine(string[] args) archString.Append(arch); archString.Append(": "); - TargetArchitecture targetArch = Program.GetTargetArchitectureFromArg(arch); + TargetArchitecture targetArch = GetTargetArchitectureFromArg(arch); bool first = true; foreach (var instructionSet in Internal.JitInterface.InstructionSetFlags.ArchitectureToValidInstructionSets(targetArch)) { @@ -476,7 +476,7 @@ private int Run(string[] args) { string instructionSet = instructionSetParamsInput[i]; - if (String.IsNullOrEmpty(instructionSet)) + if (string.IsNullOrEmpty(instructionSet)) throw new CommandLineException("Instruction set must not be empty"); char firstChar = instructionSet[0]; @@ -508,7 +508,7 @@ private int Run(string[] args) instructionSetSupportBuilder.ComputeInstructionSetFlags(out var supportedInstructionSet, out var unsupportedInstructionSet, (string specifiedInstructionSet, string impliedInstructionSet) => - throw new CommandLineException(String.Format("Unsupported combination of instruction sets: {0}/{1}", specifiedInstructionSet, impliedInstructionSet))); + throw new CommandLineException(string.Format("Unsupported combination of instruction sets: {0}/{1}", specifiedInstructionSet, impliedInstructionSet))); InstructionSetSupportBuilder optimisticInstructionSetSupportBuilder = new InstructionSetSupportBuilder(_targetArchitecture); @@ -615,7 +615,7 @@ private int Run(string[] args) securityMitigationOptions = SecurityMitigationOptions.ControlFlowGuardAnnotations; } - else if (!String.IsNullOrEmpty(_guard)) + else if (!string.IsNullOrEmpty(_guard)) { throw new CommandLineException($"Unrecognized mitigation option '{_guard}'"); } @@ -714,8 +714,8 @@ private int Run(string[] args) } } - _conditionallyRootedAssemblies = new List(_conditionallyRootedAssemblies.Select(a => ILLinkify(a))); - _trimmedAssemblies = new List(_trimmedAssemblies.Select(a => ILLinkify(a))); + _conditionallyRootedAssemblies = new List(_conditionallyRootedAssemblies.Select(ILLinkify)); + _trimmedAssemblies = new List(_trimmedAssemblies.Select(ILLinkify)); static string ILLinkify(string rootedAssembly) { @@ -751,12 +751,12 @@ static string ILLinkify(string rootedAssembly) CompilationBuilder builder = new RyuJitCompilationBuilder(typeSystemContext, compilationGroup); - string compilationUnitPrefix = _multiFile ? System.IO.Path.GetFileNameWithoutExtension(_outputFilePath) : ""; + string compilationUnitPrefix = _multiFile ? Path.GetFileNameWithoutExtension(_outputFilePath) : ""; builder.UseCompilationUnitPrefix(compilationUnitPrefix); if (_mibcFilePaths.Count > 0) ((RyuJitCompilationBuilder)builder).UseProfileData(_mibcFilePaths); - if (!String.IsNullOrEmpty(_jitPath)) + if (!string.IsNullOrEmpty(_jitPath)) ((RyuJitCompilationBuilder)builder).UseJitPath(_jitPath); PInvokeILEmitterConfiguration pinvokePolicy = new ConfigurablePInvokePolicy(typeSystemContext.Target, _directPInvokes, _directPInvokeLists); @@ -1030,7 +1030,7 @@ static bool IsRelatedToInvalidInput(MethodDesc method) return 0; } - private void DiffCompilationResults(ref bool result, IEnumerable set1, IEnumerable set2, string prefix, + private static void DiffCompilationResults(ref bool result, IEnumerable set1, IEnumerable set2, string prefix, string set1name, string set2name, Predicate filter) { HashSet diff = new HashSet(set1); @@ -1053,7 +1053,7 @@ private void DiffCompilationResults(ref bool result, IEnumerable set1, IEn } } - private TypeDesc FindType(CompilerTypeSystemContext context, string typeName) + private static TypeDesc FindType(CompilerTypeSystemContext context, string typeName) { ModuleDesc systemModule = context.SystemModule; @@ -1125,7 +1125,7 @@ private static IEnumerable ProcessWarningCodes(IEnumerable warningC string[] values = value.Split(new char[] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (string id in values) { - if (!id.StartsWith("IL", StringComparison.Ordinal) || !ushort.TryParse(id.Substring(2), out ushort code)) + if (!id.StartsWith("IL", StringComparison.Ordinal) || !ushort.TryParse(id.AsSpan(2), out ushort code)) continue; yield return code; diff --git a/src/coreclr/tools/aot/ILCompiler/RdXmlRootProvider.cs b/src/coreclr/tools/aot/ILCompiler/RdXmlRootProvider.cs index e1d976eb3118e..2c6b01849db03 100644 --- a/src/coreclr/tools/aot/ILCompiler/RdXmlRootProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler/RdXmlRootProvider.cs @@ -18,7 +18,7 @@ namespace ILCompiler /// Only supports a subset of the Runtime Directives configuration file format. /// /// https://msdn.microsoft.com/en-us/library/dn600639(v=vs.110).aspx - internal class RdXmlRootProvider : ICompilationRootProvider + internal sealed class RdXmlRootProvider : ICompilationRootProvider { private XElement _documentRoot; private TypeSystemContext _context; @@ -88,7 +88,7 @@ private void ProcessAssemblyDirective(IRootingServiceProvider rootProvider, XEle } } - private void ProcessTypeDirective(IRootingServiceProvider rootProvider, ModuleDesc containingModule, XElement typeElement) + private static void ProcessTypeDirective(IRootingServiceProvider rootProvider, ModuleDesc containingModule, XElement typeElement) { var typeNameAttribute = typeElement.Attribute("Name"); if (typeNameAttribute == null) @@ -137,7 +137,7 @@ private void ProcessTypeDirective(IRootingServiceProvider rootProvider, ModuleDe } } - private void ProcessMethodDirective(IRootingServiceProvider rootProvider, ModuleDesc containingModule, TypeDesc containingType, XElement methodElement) + private static void ProcessMethodDirective(IRootingServiceProvider rootProvider, ModuleDesc containingModule, TypeDesc containingType, XElement methodElement) { var methodNameAttribute = methodElement.Attribute("Name"); if (methodNameAttribute == null) diff --git a/src/coreclr/tools/aot/ILLink.Shared/Annotations.cs b/src/coreclr/tools/aot/ILLink.Shared/Annotations.cs index ca09218c0cc9c..302dfeae6addf 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/Annotations.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/Annotations.cs @@ -79,9 +79,9 @@ public static string GetMemberTypesString (DynamicallyAccessedMemberTypes member })); } - static readonly DynamicallyAccessedMemberTypes[] AllDynamicallyAccessedMemberTypes = GetAllDynamicallyAccessedMemberTypes (); + private static readonly DynamicallyAccessedMemberTypes[] AllDynamicallyAccessedMemberTypes = GetAllDynamicallyAccessedMemberTypes (); - static DynamicallyAccessedMemberTypes[] GetAllDynamicallyAccessedMemberTypes () + private static DynamicallyAccessedMemberTypes[] GetAllDynamicallyAccessedMemberTypes () { var values = new HashSet ( Enum.GetValues (typeof (DynamicallyAccessedMemberTypes)) diff --git a/src/coreclr/tools/aot/ILLink.Shared/ClosedAttribute.cs b/src/coreclr/tools/aot/ILLink.Shared/ClosedAttribute.cs index 5c0260fc1fb26..feea932ed6fc9 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/ClosedAttribute.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/ClosedAttribute.cs @@ -12,4 +12,4 @@ internal sealed class ClosedAttribute : Attribute { public ClosedAttribute () { } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/ILLink.Shared/DataFlow/DefaultValueDictionary.cs b/src/coreclr/tools/aot/ILLink.Shared/DataFlow/DefaultValueDictionary.cs index 1d8221463ace3..599e7d3b9871c 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/DataFlow/DefaultValueDictionary.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/DataFlow/DefaultValueDictionary.cs @@ -21,9 +21,8 @@ public struct DefaultValueDictionary : IEquatable where TValue : IEquatable { - Dictionary? Dictionary; - - readonly TValue DefaultValue; + private Dictionary? Dictionary; + private readonly TValue DefaultValue; public DefaultValueDictionary (TValue defaultValue) => (Dictionary, DefaultValue) = (null, defaultValue); @@ -81,13 +80,13 @@ public IEnumerator> GetEnumerator () public override string ToString () { StringBuilder sb = new (); - sb.Append ("{"); + sb.Append ('{'); if (Dictionary != null) { foreach (var kvp in Dictionary) sb.Append (Environment.NewLine).Append ('\t').Append (kvp.Key.ToString ()).Append (" -> ").Append (kvp.Value.ToString ()); } sb.Append (Environment.NewLine).Append ("\t_ -> ").Append (DefaultValue.ToString ()); - sb.Append (Environment.NewLine).Append ("}"); + sb.Append (Environment.NewLine).Append ('}'); return sb.ToString (); } diff --git a/src/coreclr/tools/aot/ILLink.Shared/DataFlow/ForwardDataFlowAnalysis.cs b/src/coreclr/tools/aot/ILLink.Shared/DataFlow/ForwardDataFlowAnalysis.cs index 345fbe8680a54..cd65c55f404b4 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/DataFlow/ForwardDataFlowAnalysis.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/DataFlow/ForwardDataFlowAnalysis.cs @@ -25,10 +25,10 @@ public abstract class ForwardDataFlowAnalysis blockOutput; + private readonly Dictionary blockOutput; // The control flow graph doesn't contain edges for exceptional control flow: // - From any point in a try region to the start of any catch or finally @@ -38,7 +38,7 @@ struct ControlFlowGraphState // when visiting operations inside of a try or catch region. // Dataflow states for exceptions propagating out of try or catch regions - readonly Dictionary> exceptionState; + private readonly Dictionary> exceptionState; // Control may flow through a finally region when an exception is thrown from anywhere in the corresponding // try or catch regions, or as part of non-exceptional control flow out of a try or catch. @@ -46,15 +46,14 @@ struct ControlFlowGraphState // propagated out of the finally. // Dataflow states for finally blocks when exception propagate through the finally region - readonly Dictionary exceptionFinallyState; + private readonly Dictionary exceptionFinallyState; // Finally regions may be reached (along non-exceptional paths) // from multiple branches. This gets updated to track the normal finally input // states from all of these branches (which aren't represented explicitly in the CFG). - readonly Dictionary finallyInputState; - - readonly TControlFlowGraph cfg; - readonly TLattice lattice; + private readonly Dictionary finallyInputState; + private readonly TControlFlowGraph cfg; + private readonly TLattice lattice; public ControlFlowGraphState (TControlFlowGraph cfg, TLattice lattice) { diff --git a/src/coreclr/tools/aot/ILLink.Shared/DataFlow/MaybeLattice.cs b/src/coreclr/tools/aot/ILLink.Shared/DataFlow/MaybeLattice.cs index f2b43d9deaebd..4e77f96347ef0 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/DataFlow/MaybeLattice.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/DataFlow/MaybeLattice.cs @@ -48,4 +48,4 @@ public Maybe Meet (Maybe left, Maybe right) return new Maybe (ValueLattice.Meet (leftValue, rightValue)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/ILLink.Shared/DataFlow/ValueSet.cs b/src/coreclr/tools/aot/ILLink.Shared/DataFlow/ValueSet.cs index 120e9116eaf37..c47397d5af258 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/DataFlow/ValueSet.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/DataFlow/ValueSet.cs @@ -17,7 +17,7 @@ namespace ILLink.Shared.DataFlow { // Since we're going to do lot of type checks for this class a lot, it is much more efficient // if the class is sealed (as then the runtime can do a simple method table pointer comparison) - sealed class EnumerableValues : HashSet + private sealed class EnumerableValues : HashSet { public EnumerableValues (IEnumerable values) : base (values) { } @@ -32,9 +32,9 @@ public override int GetHashCode () public struct Enumerator : IEnumerator, IDisposable, IEnumerator { - readonly object? _value; - int _state; // 0 before begining, 1 at item, 2 after end - readonly IEnumerator? _enumerator; + private readonly object? _value; + private int _state; // 0 before begining, 1 at item, 2 after end + private readonly IEnumerator? _enumerator; internal Enumerator (object? values) { @@ -87,13 +87,13 @@ public void Reset () // null - no values (empty set) // TValue - single value itself // EnumerableValues typed object - multiple values, stored in the hashset - readonly object? _values; + private readonly object? _values; public ValueSet (TValue value) => _values = value; public ValueSet (IEnumerable values) => _values = new EnumerableValues (values); - ValueSet (EnumerableValues values) => _values = values; + private ValueSet (EnumerableValues values) => _values = values; public static implicit operator ValueSet (TValue value) => new (value); @@ -166,9 +166,9 @@ internal static ValueSet Meet (ValueSet left, ValueSet r public override string ToString () { StringBuilder sb = new (); - sb.Append ("{"); + sb.Append ('{'); sb.Append (string.Join (",", this.Select (v => v.ToString ()))); - sb.Append ("}"); + sb.Append ('}'); return sb.ToString (); } diff --git a/src/coreclr/tools/aot/ILLink.Shared/DiagnosticString.cs b/src/coreclr/tools/aot/ILLink.Shared/DiagnosticString.cs index 0102ae90c22c2..ce505e1c7727b 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/DiagnosticString.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/DiagnosticString.cs @@ -10,8 +10,8 @@ namespace ILLink.Shared { public readonly struct DiagnosticString { - readonly string _titleFormat; - readonly string _messageFormat; + private readonly string _titleFormat; + private readonly string _messageFormat; public DiagnosticString (DiagnosticId diagnosticId) { diff --git a/src/coreclr/tools/aot/ILLink.Shared/HashUtils.cs b/src/coreclr/tools/aot/ILLink.Shared/HashUtils.cs index cc9b259bedb9c..9a265ed2f648c 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/HashUtils.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/HashUtils.cs @@ -10,7 +10,7 @@ namespace ILLink.Shared { - static class HashUtils + internal static class HashUtils { #if NETSTANDARD2_0 // This constant is taken from code that Roslyn generates for GetHashCode of records. diff --git a/src/coreclr/tools/aot/ILLink.Shared/IsExternalInit.cs b/src/coreclr/tools/aot/ILLink.Shared/IsExternalInit.cs index f2b081a032f43..c95d5f7b153ba 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/IsExternalInit.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/IsExternalInit.cs @@ -12,4 +12,4 @@ public sealed class IsExternalInit { } } -#endif \ No newline at end of file +#endif diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/ArrayValue.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/ArrayValue.cs index d8c399878374d..342e3a5c51a63 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/ArrayValue.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/ArrayValue.cs @@ -9,9 +9,9 @@ namespace ILLink.Shared.TrimAnalysis { - sealed partial record ArrayValue : SingleValue + internal sealed partial record ArrayValue : SingleValue { - static ValueSetLattice MultiValueLattice => default; + private static ValueSetLattice MultiValueLattice => default; public readonly SingleValue Size; diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/ConstIntValue.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/ConstIntValue.cs index e83a7cd5d3783..b8816567f2a40 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/ConstIntValue.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/ConstIntValue.cs @@ -11,7 +11,7 @@ namespace ILLink.Shared.TrimAnalysis /// /// Represents a ldc on an int32. /// - sealed record ConstIntValue : SingleValue + internal sealed record ConstIntValue : SingleValue { public ConstIntValue (int value) => Value = value; diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/DiagnosticContext.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/DiagnosticContext.cs index 95c984d7fda51..adece4a854a35 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/DiagnosticContext.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/DiagnosticContext.cs @@ -6,7 +6,7 @@ namespace ILLink.Shared.TrimAnalysis { - readonly partial struct DiagnosticContext + public readonly partial struct DiagnosticContext { /// /// The diagnostic context may be entirely disabled or some kinds of warnings may be suppressed. diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/FieldValue.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/FieldValue.cs index 0041e436313f3..2c2354723f0d3 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/FieldValue.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/FieldValue.cs @@ -6,5 +6,5 @@ namespace ILLink.Shared.TrimAnalysis { - sealed partial record FieldValue : ValueWithDynamicallyAccessedMembers; + internal sealed partial record FieldValue : ValueWithDynamicallyAccessedMembers; } diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/FlowAnnotations.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/FlowAnnotations.cs index 7d3912e971e29..0a27918ceb44b 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/FlowAnnotations.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/FlowAnnotations.cs @@ -10,7 +10,7 @@ namespace ILLink.Shared.TrimAnalysis { // Shared helpers to go from MethodProxy to dataflow values. - partial class FlowAnnotations + public partial class FlowAnnotations { internal partial bool MethodRequiresDataFlowAnalysis (MethodProxy method); @@ -28,4 +28,4 @@ partial class FlowAnnotations internal partial MethodParameterValue GetMethodParameterValue (MethodProxy method, int parameterIndex); } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/GenericParameterValue.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/GenericParameterValue.cs index 18bfa5fbbdef7..155ab10dc57e4 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/GenericParameterValue.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/GenericParameterValue.cs @@ -12,7 +12,7 @@ namespace ILLink.Shared.TrimAnalysis /// This is a System.Type value which represents generic parameter (basically result of typeof(T)) /// Its actual type is unknown, but it can have annotations. /// - sealed partial record GenericParameterValue : ValueWithDynamicallyAccessedMembers + internal sealed partial record GenericParameterValue : ValueWithDynamicallyAccessedMembers { public readonly GenericParameterProxy GenericParameter; } diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/HandleCallAction.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/HandleCallAction.cs index b8f3607827cbb..51046d7a831ac 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/HandleCallAction.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/HandleCallAction.cs @@ -19,13 +19,13 @@ namespace ILLink.Shared.TrimAnalysis { [StructLayout (LayoutKind.Auto)] // A good way to avoid CS0282, we don't really care about field order - partial struct HandleCallAction + internal partial struct HandleCallAction { - static ValueSetLattice MultiValueLattice => default; + private static ValueSetLattice MultiValueLattice => default; - readonly DiagnosticContext _diagnosticContext; - readonly FlowAnnotations _annotations; - readonly RequireDynamicallyAccessedMembersAction _requireDynamicallyAccessedMembersAction; + private readonly DiagnosticContext _diagnosticContext; + private readonly FlowAnnotations _annotations; + private readonly RequireDynamicallyAccessedMembersAction _requireDynamicallyAccessedMembersAction; public bool Invoke (MethodProxy calledMethod, MultiValue instanceValue, IReadOnlyList argumentValues, out MultiValue methodReturnValue, out IntrinsicId intrinsicId) { @@ -1198,7 +1198,7 @@ void AddReturnValue (MultiValue value) } } - IEnumerable ProcessGetMethodByName (TypeProxy type, string methodName, BindingFlags? bindingFlags) + private IEnumerable ProcessGetMethodByName (TypeProxy type, string methodName, BindingFlags? bindingFlags) { bool foundAny = false; foreach (var method in GetMethodsOnTypeHierarchy (type, methodName, bindingFlags)) { @@ -1215,7 +1215,7 @@ IEnumerable ProcessGetMethodByName (TypeProxy type, string methodNam yield return NullValue.Instance; } - bool AnalyzeGenericInstantiationTypeArray (in MultiValue arrayParam, in MethodProxy calledMethod, ImmutableArray genericParameters) + private bool AnalyzeGenericInstantiationTypeArray (in MultiValue arrayParam, in MethodProxy calledMethod, ImmutableArray genericParameters) { bool hasRequirements = false; foreach (var genericParameter in genericParameters) { @@ -1278,7 +1278,7 @@ static DynamicallyAccessedMemberTypes GetGenericParameterEffectiveMemberTypes (G } } - void ValidateGenericMethodInstantiation ( + private void ValidateGenericMethodInstantiation ( MethodProxy genericMethod, in MultiValue genericParametersArray, MethodProxy reflectionMethod) @@ -1293,7 +1293,7 @@ void ValidateGenericMethodInstantiation ( } } - ImmutableArray GetGenericParameterValues (ImmutableArray genericParameters) + private ImmutableArray GetGenericParameterValues (ImmutableArray genericParameters) { if (genericParameters.IsEmpty) return ImmutableArray.Empty; @@ -1305,7 +1305,7 @@ ImmutableArray GetGenericParameterValues (ImmutableArray< return builder.ToImmutableArray (); } - void ProcessCreateInstanceByName (MethodProxy calledMethod, IReadOnlyList argumentValues) + private void ProcessCreateInstanceByName (MethodProxy calledMethod, IReadOnlyList argumentValues) { BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public; bool parameterlessConstructor = true; diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/IntrinsicId.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/IntrinsicId.cs index bd9d8df893a2c..2b2713c65c730 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/IntrinsicId.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/IntrinsicId.cs @@ -7,7 +7,7 @@ namespace ILLink.Shared.TrimAnalysis { [StaticCs.Closed] - enum IntrinsicId + internal enum IntrinsicId { None = 0, IntrospectionExtensions_GetTypeInfo, diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/Intrinsics.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/Intrinsics.cs index 654e851513cdd..2d772a54c60b2 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/Intrinsics.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/Intrinsics.cs @@ -8,7 +8,7 @@ namespace ILLink.Shared.TrimAnalysis { - static class Intrinsics + internal static class Intrinsics { public static IntrinsicId GetIntrinsicIdForMethod (MethodProxy calledMethod) { diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/KnownStringValue.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/KnownStringValue.cs index bbdedf5bf02dc..b1cee312beefd 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/KnownStringValue.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/KnownStringValue.cs @@ -11,7 +11,7 @@ namespace ILLink.Shared.TrimAnalysis /// /// A known string - such as the result of a ldstr. /// - sealed partial record KnownStringValue : SingleValue + internal sealed partial record KnownStringValue : SingleValue { public KnownStringValue (string contents) => Contents = contents; diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/MethodParameterValue.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/MethodParameterValue.cs index 8d2b4a6a64b4f..29c042db79ad7 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/MethodParameterValue.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/MethodParameterValue.cs @@ -6,5 +6,5 @@ namespace ILLink.Shared.TrimAnalysis { - sealed partial record MethodParameterValue : ValueWithDynamicallyAccessedMembers; + internal sealed partial record MethodParameterValue : ValueWithDynamicallyAccessedMembers; } diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/MethodReturnValue.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/MethodReturnValue.cs index 708b5f469c39b..915234337e873 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/MethodReturnValue.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/MethodReturnValue.cs @@ -6,5 +6,5 @@ namespace ILLink.Shared.TrimAnalysis { - sealed partial record class MethodReturnValue : ValueWithDynamicallyAccessedMembers; + internal sealed partial record class MethodReturnValue : ValueWithDynamicallyAccessedMembers; } diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/MethodThisParameterValue.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/MethodThisParameterValue.cs index baf12d256d8fb..5339529c80de1 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/MethodThisParameterValue.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/MethodThisParameterValue.cs @@ -6,5 +6,5 @@ namespace ILLink.Shared.TrimAnalysis { - sealed partial record MethodThisParameterValue : ValueWithDynamicallyAccessedMembers; + internal sealed partial record MethodThisParameterValue : ValueWithDynamicallyAccessedMembers; } diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/NullValue.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/NullValue.cs index 90afd5a87929f..0e354bf19be56 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/NullValue.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/NullValue.cs @@ -8,7 +8,7 @@ namespace ILLink.Shared.TrimAnalysis { - sealed record NullValue : SingleValue + internal sealed record NullValue : SingleValue { private NullValue () { diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/NullableSystemTypeValue.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/NullableSystemTypeValue.cs index 1f54cc2779bf1..f08d97bafb65c 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/NullableSystemTypeValue.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/NullableSystemTypeValue.cs @@ -14,7 +14,7 @@ namespace ILLink.Shared.TrimAnalysis /// This represents a Nullable where T is a known SystemTypeValue. /// It is necessary to track the underlying type to propagate DynamicallyAccessedMembers annotations to the underlying type when applied to a Nullable. /// - sealed record NullableSystemTypeValue : SingleValue + internal sealed record NullableSystemTypeValue : SingleValue { public NullableSystemTypeValue (in TypeProxy nullableType, in SystemTypeValue underlyingTypeValue) { diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/NullableValueWithDynamicallyAccessedMembers.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/NullableValueWithDynamicallyAccessedMembers.cs index 4c09d6f7f173f..38983bd9aec79 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/NullableValueWithDynamicallyAccessedMembers.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/NullableValueWithDynamicallyAccessedMembers.cs @@ -13,10 +13,10 @@ namespace ILLink.Shared.TrimAnalysis { /// - /// This represents a Nullable where T is an unknown value with DynamicallyAccessedMembers annotations. + /// This represents a Nullable where T is an unknown value with DynamicallyAccessedMembers annotations. /// It is necessary to track the underlying type to ensure DynamicallyAccessedMembers annotations on the underlying type match the target parameters where the Nullable is used. /// - sealed record NullableValueWithDynamicallyAccessedMembers : ValueWithDynamicallyAccessedMembers + internal sealed record NullableValueWithDynamicallyAccessedMembers : ValueWithDynamicallyAccessedMembers { public NullableValueWithDynamicallyAccessedMembers (in TypeProxy nullableType, in ValueWithDynamicallyAccessedMembers underlyingTypeValue) { diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/ReferenceKind.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/ReferenceKind.cs index 1c46b2dbeba0b..7355ef8f4ec45 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/ReferenceKind.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/ReferenceKind.cs @@ -11,4 +11,4 @@ public enum ReferenceKind Out, None } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RequireDynamicallyAccessedMembersAction.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RequireDynamicallyAccessedMembersAction.cs index 9eb5db78804f5..b706ca8bc13ff 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RequireDynamicallyAccessedMembersAction.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RequireDynamicallyAccessedMembersAction.cs @@ -14,9 +14,9 @@ namespace ILLink.Shared.TrimAnalysis { [StructLayout (LayoutKind.Auto)] - partial struct RequireDynamicallyAccessedMembersAction + internal partial struct RequireDynamicallyAccessedMembersAction { - readonly DiagnosticContext _diagnosticContext; + private readonly DiagnosticContext _diagnosticContext; public void Invoke (in MultiValue value, ValueWithDynamicallyAccessedMembers targetValue) { diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeMethodHandleValue.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeMethodHandleValue.cs index 7ef048f224b5b..f8e0029e05094 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeMethodHandleValue.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeMethodHandleValue.cs @@ -12,7 +12,7 @@ namespace ILLink.Shared.TrimAnalysis /// /// This is the System.RuntimeMethodHandle equivalent to a node. /// - sealed partial record RuntimeMethodHandleValue : SingleValue + internal sealed partial record RuntimeMethodHandleValue : SingleValue { public RuntimeMethodHandleValue (in MethodProxy representedMethod) { diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeTypeHandleForGenericParameterValue.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeTypeHandleForGenericParameterValue.cs index 1eb108e5faeae..c6b82ccc808ce 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeTypeHandleForGenericParameterValue.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeTypeHandleForGenericParameterValue.cs @@ -12,7 +12,7 @@ namespace ILLink.Shared.TrimAnalysis /// /// This is the System.RuntimeTypeHandle equivalent to a node. /// - sealed record RuntimeTypeHandleForGenericParameterValue : SingleValue + internal sealed record RuntimeTypeHandleForGenericParameterValue : SingleValue { public readonly GenericParameterProxy GenericParameter; diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeTypeHandleForNullableSystemTypeValue.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeTypeHandleForNullableSystemTypeValue.cs index c92d4274b2d91..f85536aeb4a5e 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeTypeHandleForNullableSystemTypeValue.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeTypeHandleForNullableSystemTypeValue.cs @@ -14,7 +14,7 @@ namespace ILLink.Shared.TrimAnalysis /// This represents a type handle Nullable where T is a known SystemTypeValue. /// It is necessary to track the underlying type to propagate DynamicallyAccessedMembers annotations to the underlying type when applied to a Nullable. /// - sealed record RuntimeTypeHandleForNullableSystemTypeValue : SingleValue + internal sealed record RuntimeTypeHandleForNullableSystemTypeValue : SingleValue { public RuntimeTypeHandleForNullableSystemTypeValue (in TypeProxy nullableType, in SystemTypeValue underlyingTypeValue) { diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeTypeHandleForNullableValueWithDynamicallyAccessedMembers.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeTypeHandleForNullableValueWithDynamicallyAccessedMembers.cs index b4b0653931d07..968e55fcd3cf3 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeTypeHandleForNullableValueWithDynamicallyAccessedMembers.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeTypeHandleForNullableValueWithDynamicallyAccessedMembers.cs @@ -11,10 +11,10 @@ namespace ILLink.Shared.TrimAnalysis { /// - /// This represents a type handle of a Nullable where T is an unknown value with DynamicallyAccessedMembers annotations. + /// This represents a type handle of a Nullable where T is an unknown value with DynamicallyAccessedMembers annotations. /// It is necessary to track the underlying type to ensure DynamicallyAccessedMembers annotations on the underlying type match the target parameters where the Nullable is used. /// - sealed record RuntimeTypeHandleForNullableValueWithDynamicallyAccessedMembers : SingleValue + internal sealed record RuntimeTypeHandleForNullableValueWithDynamicallyAccessedMembers : SingleValue { public RuntimeTypeHandleForNullableValueWithDynamicallyAccessedMembers (in TypeProxy nullableType, in SingleValue underlyingTypeValue) { @@ -26,7 +26,7 @@ public RuntimeTypeHandleForNullableValueWithDynamicallyAccessedMembers (in TypeP public readonly TypeProxy NullableType; public readonly SingleValue UnderlyingTypeValue; - public override SingleValue DeepCopy () => this; // This value is immutable } + public override SingleValue DeepCopy () => this; // This value is immutable public override string ToString () => this.ValueToString (UnderlyingTypeValue, NullableType); } diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeTypeHandleValue.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeTypeHandleValue.cs index c508c1f784dca..3e9cbccf7c1ea 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeTypeHandleValue.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/RuntimeTypeHandleValue.cs @@ -12,7 +12,7 @@ namespace ILLink.Shared.TrimAnalysis /// /// This is the System.RuntimeTypeHandle equivalent to a node. /// - sealed record RuntimeTypeHandleValue : SingleValue + internal sealed record RuntimeTypeHandleValue : SingleValue { public RuntimeTypeHandleValue (in TypeProxy representedType) { diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/SystemReflectionMethodBaseValue.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/SystemReflectionMethodBaseValue.cs index 3ef755cb7aae8..ac3d0ec89fd6c 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/SystemReflectionMethodBaseValue.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/SystemReflectionMethodBaseValue.cs @@ -12,7 +12,7 @@ namespace ILLink.Shared.TrimAnalysis /// /// This is a known System.Reflection.MethodBase value. MethodRepresented is the 'value' of the MethodBase. /// - sealed partial record SystemReflectionMethodBaseValue : SingleValue + internal sealed partial record SystemReflectionMethodBaseValue : SingleValue { public SystemReflectionMethodBaseValue (MethodProxy representedMethod) => RepresentedMethod = representedMethod; diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/SystemTypeValue.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/SystemTypeValue.cs index 71af91c4e56dc..796c4333caa3e 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/SystemTypeValue.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/SystemTypeValue.cs @@ -12,7 +12,7 @@ namespace ILLink.Shared.TrimAnalysis /// /// This is a known System.Type value. TypeRepresented is the 'value' of the System.Type. /// - sealed record SystemTypeValue : SingleValue + internal sealed record SystemTypeValue : SingleValue { public SystemTypeValue (in TypeProxy representedType) { diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/UnknownValue.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/UnknownValue.cs index 7dc49dc666276..863d757d4ccd4 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/UnknownValue.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/UnknownValue.cs @@ -8,7 +8,7 @@ namespace ILLink.Shared.TrimAnalysis { - sealed record UnknownValue : SingleValue + internal sealed record UnknownValue : SingleValue { private UnknownValue () { diff --git a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/ValueExtensions.cs b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/ValueExtensions.cs index d9358f2910f1b..0e7643a8d5d43 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/ValueExtensions.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TrimAnalysis/ValueExtensions.cs @@ -11,7 +11,7 @@ namespace ILLink.Shared.TrimAnalysis { - static partial class ValueExtensions + internal static partial class ValueExtensions { internal static string ValueToString (this SingleValue value, params object[] args) { @@ -20,15 +20,15 @@ internal static string ValueToString (this SingleValue value, params object[] ar StringBuilder sb = new (); sb.Append (value.GetType ().Name); - sb.Append ("("); + sb.Append ('('); if (args != null) { for (int i = 0; i < args.Length; i++) { if (i > 0) - sb.Append (","); + sb.Append (','); sb.Append (args[i] == null ? "" : args[i].ToString ()); } } - sb.Append (")"); + sb.Append (')'); return sb.ToString (); } diff --git a/src/coreclr/tools/aot/ILLink.Shared/TypeSystemProxy/IMemberProxy.cs b/src/coreclr/tools/aot/ILLink.Shared/TypeSystemProxy/IMemberProxy.cs index 3e358b9a5b85e..7f4882ee03762 100644 --- a/src/coreclr/tools/aot/ILLink.Shared/TypeSystemProxy/IMemberProxy.cs +++ b/src/coreclr/tools/aot/ILLink.Shared/TypeSystemProxy/IMemberProxy.cs @@ -6,7 +6,7 @@ namespace ILLink.Shared.TypeSystemProxy { - interface IMemberProxy + internal interface IMemberProxy { public string Name { get; } diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/BaseExpectedLinkedBehaviorAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/BaseExpectedLinkedBehaviorAttribute.cs index 9a963f6105571..c5fb5096a681d 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/BaseExpectedLinkedBehaviorAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/BaseExpectedLinkedBehaviorAttribute.cs @@ -13,4 +13,4 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions public abstract class BaseExpectedLinkedBehaviorAttribute : Attribute { } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/BaseMemberAssertionAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/BaseMemberAssertionAttribute.cs index 5afd16cfd6d9e..61838421cfe48 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/BaseMemberAssertionAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/BaseMemberAssertionAttribute.cs @@ -12,4 +12,4 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions public abstract class BaseMemberAssertionAttribute : Attribute { } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/CreatedMemberAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/CreatedMemberAttribute.cs index 9fdbb1938776e..f9e95dbfa1aea 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/CreatedMemberAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/CreatedMemberAttribute.cs @@ -15,4 +15,4 @@ public CreatedMemberAttribute (string name) throw new ArgumentException ("Value cannot be null or empty.", nameof (name)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/EnableLoggerAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/EnableLoggerAttribute.cs index 436281610fbeb..45d4b88fb21cb 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/EnableLoggerAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/EnableLoggerAttribute.cs @@ -6,4 +6,4 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions public abstract class EnableLoggerAttribute : BaseExpectedLinkedBehaviorAttribute { } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectBodyModifiedAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectBodyModifiedAttribute.cs index dbe07219cf015..f4f45f99cbc4d 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectBodyModifiedAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectBodyModifiedAttribute.cs @@ -9,4 +9,4 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions public class ExpectBodyModifiedAttribute : BaseInAssemblyAttribute { } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectExactlyResolvedDocumentationSignatureAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectExactlyResolvedDocumentationSignatureAttribute.cs index b618ed7a35486..e17d46377f0cc 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectExactlyResolvedDocumentationSignatureAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectExactlyResolvedDocumentationSignatureAttribute.cs @@ -11,4 +11,4 @@ public ExpectExactlyResolvedDocumentationSignatureAttribute (string input) { } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectExceptionHandlersModifiedAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectExceptionHandlersModifiedAttribute.cs index a76e4b6489777..ef7f7f0216552 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectExceptionHandlersModifiedAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectExceptionHandlersModifiedAttribute.cs @@ -9,4 +9,4 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions public class ExpectExceptionHandlersModifiedAttribute : BaseInAssemblyAttribute { } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectGeneratedDocumentationSignatureAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectGeneratedDocumentationSignatureAttribute.cs index c25b2ff3d0262..0065c86d1ac29 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectGeneratedDocumentationSignatureAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectGeneratedDocumentationSignatureAttribute.cs @@ -11,4 +11,4 @@ public ExpectGeneratedDocumentationSignatureAttribute (string expected) { } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectLocalsModifiedAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectLocalsModifiedAttribute.cs index 56a30bd52d20c..c6ef05f63cb07 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectLocalsModifiedAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectLocalsModifiedAttribute.cs @@ -9,4 +9,4 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions public class ExpectLocalsModifiedAttribute : BaseInAssemblyAttribute { } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectResolvedDocumentationSignatureAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectResolvedDocumentationSignatureAttribute.cs index 5a3c16fe9bcc2..39e2c6d5065b9 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectResolvedDocumentationSignatureAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectResolvedDocumentationSignatureAttribute.cs @@ -11,4 +11,4 @@ public ExpectResolvedDocumentationSignatureAttribute (string input) { } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectUnresolvedDocumentationSignatureAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectUnresolvedDocumentationSignatureAttribute.cs index aea9068451bcc..dd2cd32b0b445 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectUnresolvedDocumentationSignatureAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectUnresolvedDocumentationSignatureAttribute.cs @@ -11,4 +11,4 @@ public ExpectUnresolvedDocumentationSignatureAttribute (string expected) { } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceAttribute.cs index 35ead6966a4f6..5883066e838dc 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceAttribute.cs @@ -14,4 +14,4 @@ public ExpectedInstructionSequenceAttribute (string[] opCodes) throw new ArgumentNullException (nameof (opCodes)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceOnMemberInAssemblyAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceOnMemberInAssemblyAttribute.cs index 899b979c5211e..9da8499153081 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceOnMemberInAssemblyAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceOnMemberInAssemblyAttribute.cs @@ -32,4 +32,4 @@ public ExpectedInstructionSequenceOnMemberInAssemblyAttribute (string assemblyFi throw new ArgumentNullException (nameof (opCodes)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedLocalsSequenceAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedLocalsSequenceAttribute.cs index fdd3441b71f44..99a4839fab8ce 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedLocalsSequenceAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedLocalsSequenceAttribute.cs @@ -20,4 +20,4 @@ public ExpectedLocalsSequenceAttribute (Type[] types) throw new ArgumentNullException (nameof (types)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/IgnoreTestCaseAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/IgnoreTestCaseAttribute.cs index 78fd0e4537423..753e4a6fb11bf 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/IgnoreTestCaseAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/IgnoreTestCaseAttribute.cs @@ -15,4 +15,4 @@ public IgnoreTestCaseAttribute (string reason) throw new ArgumentNullException (nameof (reason)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAllTypesAndMembersInAssemblyAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAllTypesAndMembersInAssemblyAttribute.cs index ffdb9d07c2e0a..0c44aadca4955 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAllTypesAndMembersInAssemblyAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAllTypesAndMembersInAssemblyAttribute.cs @@ -14,4 +14,4 @@ public KeptAllTypesAndMembersInAssemblyAttribute (string assemblyFileName) throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAssemblyAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAssemblyAttribute.cs index 9103fa1c31763..d75844581fb08 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAssemblyAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAssemblyAttribute.cs @@ -18,4 +18,4 @@ public KeptAssemblyAttribute (string fileName) throw new ArgumentException ("Value cannot be null or empty.", nameof (fileName)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttribute.cs index 922123f7d11bd..179ea77e5d7bd 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttribute.cs @@ -9,4 +9,4 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions public class KeptAttribute : BaseExpectedLinkedBehaviorAttribute { } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttributeInAssemblyAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttributeInAssemblyAttribute.cs index 91081f68a1416..1fe5699ff61bb 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttributeInAssemblyAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttributeInAssemblyAttribute.cs @@ -68,4 +68,4 @@ public KeptAttributeInAssemblyAttribute (string assemblyName, Type attributeType { } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttributeOnFixedBufferTypeAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttributeOnFixedBufferTypeAttribute.cs index 0fc56741a8ca4..f8ab0bdb3593f 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttributeOnFixedBufferTypeAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttributeOnFixedBufferTypeAttribute.cs @@ -20,4 +20,4 @@ public KeptAttributeOnFixedBufferTypeAttribute (Type type) throw new ArgumentNullException (nameof (type)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptBaseOnTypeInAssemblyAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptBaseOnTypeInAssemblyAttribute.cs index acac5d575bbce..84957dbc36fa2 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptBaseOnTypeInAssemblyAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptBaseOnTypeInAssemblyAttribute.cs @@ -34,4 +34,4 @@ public KeptBaseOnTypeInAssemblyAttribute (string assemblyFileName, string typeNa throw new ArgumentException ("Value cannot be null or empty.", nameof (baseTypeName)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptBaseTypeAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptBaseTypeAttribute.cs index c4e4a24889542..673795e134b5a 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptBaseTypeAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptBaseTypeAttribute.cs @@ -22,4 +22,4 @@ public KeptBaseTypeAttribute (Type baseType, params object[] typeArguments) throw new ArgumentNullException (nameof (typeArguments)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptFixedBufferAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptFixedBufferAttribute.cs index d0067544ad760..18b1bef2fdd08 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptFixedBufferAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptFixedBufferAttribute.cs @@ -9,4 +9,4 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions public class KeptFixedBufferAttribute : KeptAttribute { } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInitializerData.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInitializerData.cs index 25b8c8261f16c..c52323dac4086 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInitializerData.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInitializerData.cs @@ -19,4 +19,4 @@ public KeptInitializerData (int occurrenceIndexInBody) throw new ArgumentOutOfRangeException (nameof (occurrenceIndexInBody)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceAttribute.cs index 85279abcd83f6..35403cfd004c7 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceAttribute.cs @@ -23,4 +23,4 @@ public KeptInterfaceAttribute (Type interfaceType, params object[] typeArguments throw new ArgumentNullException (nameof (typeArguments)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceOnTypeInAssemblyAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceOnTypeInAssemblyAttribute.cs index 2741439facc88..bf5065968570f 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceOnTypeInAssemblyAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceOnTypeInAssemblyAttribute.cs @@ -34,4 +34,4 @@ public KeptInterfaceOnTypeInAssemblyAttribute (string assemblyFileName, string t throw new ArgumentException ("Value cannot be null or empty.", nameof (interfaceTypeName)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptMemberAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptMemberAttribute.cs index 6f7adcf30bedb..d30d195f80470 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptMemberAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptMemberAttribute.cs @@ -15,4 +15,4 @@ public KeptMemberAttribute (string name) throw new ArgumentException ("Value cannot be null or empty.", nameof (name)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptPrivateImplementationDetails.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptPrivateImplementationDetails.cs index a410eb2f50bbc..ad7576345a34a 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptPrivateImplementationDetails.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptPrivateImplementationDetails.cs @@ -14,4 +14,4 @@ public KeptPrivateImplementationDetailsAttribute (string methodName) throw new ArgumentException ("Value cannot be null or empty.", nameof (methodName)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptReferenceAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptReferenceAttribute.cs index f4bb464260dba..554bc8d7ae3f2 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptReferenceAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptReferenceAttribute.cs @@ -17,4 +17,4 @@ public KeptReferenceAttribute (string name) throw new ArgumentException ("Value cannot be null or empty.", nameof (name)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptReferencesInAssemblyAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptReferencesInAssemblyAttribute.cs index 0265b9f3a40d9..b075864265333 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptReferencesInAssemblyAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptReferencesInAssemblyAttribute.cs @@ -17,4 +17,4 @@ public KeptReferencesInAssemblyAttribute (string assemblyFileName, string[] expe throw new ArgumentNullException (nameof (expectedReferenceAssemblyNames)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptSymbolsAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptSymbolsAttribute.cs index 3e435017b8b57..3cfcee17bbcf2 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptSymbolsAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptSymbolsAttribute.cs @@ -14,4 +14,4 @@ public KeptSymbolsAttribute (string assemblyFileName) throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedAssemblyAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedAssemblyAttribute.cs index e1dc4c0e1e36a..9258217230a3c 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedAssemblyAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedAssemblyAttribute.cs @@ -18,4 +18,4 @@ public RemovedAssemblyAttribute (string fileName) throw new ArgumentException ("Value cannot be null or empty.", nameof (fileName)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedAttributeInAssembly.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedAttributeInAssembly.cs index 591aa81b40f0e..4e05c1e7ae95d 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedAttributeInAssembly.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedAttributeInAssembly.cs @@ -68,4 +68,4 @@ public RemovedAttributeInAssembly (string assemblyName, Type attributeType, Type { } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedInterfaceOnTypeInAssemblyAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedInterfaceOnTypeInAssemblyAttribute.cs index 70465fc3d6035..a0bd1c5fc62dd 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedInterfaceOnTypeInAssemblyAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedInterfaceOnTypeInAssemblyAttribute.cs @@ -34,4 +34,4 @@ public RemovedInterfaceOnTypeInAssemblyAttribute (string assemblyFileName, strin throw new ArgumentException ("Value cannot be null or empty.", nameof (interfaceTypeName)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedPseudoAttributeAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedPseudoAttributeAttribute.cs index 00b4eb588eaf7..fd2198aac8b71 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedPseudoAttributeAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedPseudoAttributeAttribute.cs @@ -12,4 +12,4 @@ public RemovedPseudoAttributeAttribute (uint value) { } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedSymbolsAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedSymbolsAttribute.cs index 1549b8a03c9f1..1557a837586ad 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedSymbolsAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedSymbolsAttribute.cs @@ -14,4 +14,4 @@ public RemovedSymbolsAttribute (string assemblyFileName) throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Helpers/PlatformAssemblies.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Helpers/PlatformAssemblies.cs index c2e77e98f8d44..03643715f0535 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Helpers/PlatformAssemblies.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Helpers/PlatformAssemblies.cs @@ -11,4 +11,4 @@ public static class PlatformAssemblies public const string CoreLib = "mscorlib.dll"; #endif } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/NotATestCaseAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/NotATestCaseAttribute.cs index a099ee6301a4b..67881a49a88a8 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/NotATestCaseAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/NotATestCaseAttribute.cs @@ -9,4 +9,4 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata public class NotATestCaseAttribute : BaseMetadataAttribute { } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/ReferenceDependencyAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/ReferenceDependencyAttribute.cs index c038fe43f7504..9f810958164f0 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/ReferenceDependencyAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/ReferenceDependencyAttribute.cs @@ -14,4 +14,4 @@ public ReferenceDependencyAttribute (string value) throw new ArgumentException ("Value cannot be null or empty.", nameof (value)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SandboxDependencyAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SandboxDependencyAttribute.cs index dce29bd3170bb..93b906161f087 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SandboxDependencyAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SandboxDependencyAttribute.cs @@ -21,4 +21,4 @@ public SandboxDependencyAttribute (Type typeOfSourceFileToInclude, string destin throw new ArgumentException ("Value cannot be null or empty.", nameof (typeOfSourceFileToInclude)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAsLibraryAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAsLibraryAttribute.cs index e78aaa089bcc3..0d44529ff2c7a 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAsLibraryAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAsLibraryAttribute.cs @@ -9,4 +9,4 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata public class SetupCompileAsLibraryAttribute : BaseMetadataAttribute { } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAssemblyNameAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAssemblyNameAttribute.cs index 7fad90431149d..5bd0d8613ad79 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAssemblyNameAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAssemblyNameAttribute.cs @@ -14,4 +14,4 @@ public SetupCompileAssemblyNameAttribute (string outputName) throw new ArgumentNullException (nameof (outputName)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerArgumentAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerArgumentAttribute.cs index 6f2e55f24bba2..0f81a06fe7949 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerArgumentAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerArgumentAttribute.cs @@ -8,7 +8,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata /// /// Used to define arguments to pass to the linker. - /// + /// /// Don't use this attribute to setup single character flags. These flags do a poor job of communicating their purpose /// and although we need to continue to support the usages that exist today, that doesn't mean we need to make our tests harder to read /// diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerDefaultActionAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerDefaultActionAttribute.cs index ee9794d495f98..422a0cb469afe 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerDefaultActionAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerDefaultActionAttribute.cs @@ -14,4 +14,4 @@ public SetupLinkerDefaultActionAttribute (string action) throw new ArgumentNullException (nameof (action)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerKeepDebugMembersAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerKeepDebugMembersAttribute.cs index 2213b9cc551c7..94d036e434718 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerKeepDebugMembersAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerKeepDebugMembersAttribute.cs @@ -14,4 +14,4 @@ public SetupLinkerKeepDebugMembersAttribute (string value) throw new ArgumentException ("Value cannot be null or empty.", nameof (value)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerLinkPublicAndFamilyAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerLinkPublicAndFamilyAttribute.cs index c4250b82e231d..70d407928a4a3 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerLinkPublicAndFamilyAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerLinkPublicAndFamilyAttribute.cs @@ -9,4 +9,4 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata public class SetupLinkerLinkPublicAndFamilyAttribute : BaseMetadataAttribute { } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerResponseFileAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerResponseFileAttribute.cs index 28c30f868bcda..1226e91894e86 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerResponseFileAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerResponseFileAttribute.cs @@ -14,4 +14,4 @@ public SetupLinkerResponseFileAttribute (string relativePathToFile, string desti throw new ArgumentException ("Value cannot be null or empty.", nameof (relativePathToFile)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerSubstitutionFileAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerSubstitutionFileAttribute.cs index 6a102a830fa16..e27f6e8182a60 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerSubstitutionFileAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerSubstitutionFileAttribute.cs @@ -14,4 +14,4 @@ public SetupLinkerSubstitutionFileAttribute (string relativePathToFile, string d throw new ArgumentException ("Value cannot be null or empty.", nameof (relativePathToFile)); } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj index 14a94ab30bf27..104c5d7562d53 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj @@ -5,6 +5,7 @@ disable x64;x86 AnyCPU + true diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Support/RemoveAttributeInstancesAttribute.cs b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Support/RemoveAttributeInstancesAttribute.cs index e2eb936d545f8..c1ff585a6f5de 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Support/RemoveAttributeInstancesAttribute.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Support/RemoveAttributeInstancesAttribute.cs @@ -6,7 +6,7 @@ namespace Mono.Linker { /// - /// This attribute name will be the name hardcoded in linker which will remove all + /// This attribute name will be the name hardcoded in linker which will remove all /// attribute usages but not the attribute definition /// [AttributeUsage ( diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj index ec237817f2901..1e6202665c685 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj +++ b/src/coreclr/tools/aot/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj @@ -8,6 +8,7 @@ $(DefineConstants);INCLUDE_EXPECTATIONS 0 0 + true diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/CecilExtensions.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/CecilExtensions.cs index f88c4d8cf177f..7efcb271461db 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/CecilExtensions.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/CecilExtensions.cs @@ -132,7 +132,7 @@ public static string GetSignature (this MethodDefinition method) builder.Append ($"<#{method.GenericParameters.Count}>"); } - builder.Append ("("); + builder.Append ('('); if (method.HasParameters) { for (int i = 0; i < method.Parameters.Count - 1; i++) { @@ -144,7 +144,7 @@ public static string GetSignature (this MethodDefinition method) builder.Append (method.Parameters[method.Parameters.Count - 1].ParameterType); } - builder.Append (")"); + builder.Append (')'); return builder.ToString (); } @@ -200,7 +200,7 @@ public static string GetDisplayName (this MethodReference method) } // Append parameters - sb.Append ("("); + sb.Append ('('); if (method.HasParameters) { for (int i = 0; i < method.Parameters.Count - 1; i++) sb.Append (method.Parameters[i].ParameterType.GetDisplayNameWithoutNamespace ()).Append (", "); @@ -208,7 +208,7 @@ public static string GetDisplayName (this MethodReference method) sb.Append (method.Parameters[method.Parameters.Count - 1].ParameterType.GetDisplayNameWithoutNamespace ()); } - sb.Append (")"); + sb.Append (')'); // Insert generic parameters if (method.HasGenericParameters) { @@ -250,7 +250,7 @@ public static string GetDisplayName (this FieldReference field) var builder = new StringBuilder (); if (field.DeclaringType != null) { builder.Append (field.DeclaringType.GetDisplayName ()); - builder.Append ("."); + builder.Append ('.'); } builder.Append (field.Name); diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/NiceIO.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/NiceIO.cs index 9272ffc026c03..c2b1ff6eaf1a9 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/NiceIO.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/NiceIO.cs @@ -97,7 +97,7 @@ private static bool HasNonDotDotLastElement (List stack) return stack.Count > 0 && stack[stack.Count - 1] != ".."; } - private string ParseDriveLetter (string path, out string? driveLetter) + private static string ParseDriveLetter (string path, out string? driveLetter) { if (path.Length >= 2 && path[1] == ':') { driveLetter = path[0].ToString (); @@ -242,7 +242,7 @@ public string ExtensionWithDot { var last = _elements.Last (); var index = last.LastIndexOf ("."); - if (index < 0) return String.Empty; + if (index < 0) return string.Empty; return last.Substring (index); } } @@ -274,7 +274,7 @@ public string ToString (SlashMode slashMode) var sb = new StringBuilder (); if (_driveLetter != null) { sb.Append (_driveLetter); - sb.Append (":"); + sb.Append (':'); } if (!_isRelative) sb.Append (Slash (slashMode)); @@ -303,7 +303,7 @@ static char Slash (SlashMode slashMode) }; } - public override bool Equals (Object? obj) + public override bool Equals (object? obj) { if (obj == null) return false; @@ -511,7 +511,7 @@ public NPath MakeAbsolute () if (!IsRelative) return this; - return NPath.CurrentDirectory.Combine (this); + return CurrentDirectory.Combine (this); } NPath? CopyWithDeterminedDestination (NPath absoluteDestination, Func fileFilter) diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/Mono.Linker.Tests.csproj b/src/coreclr/tools/aot/Mono.Linker.Tests/Mono.Linker.Tests.csproj index 479c971ed03fd..e82fddf45fb44 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/Mono.Linker.Tests.csproj +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/Mono.Linker.Tests.csproj @@ -11,6 +11,7 @@ linux-x64;win-x64;osx-x64 Debug;Release;Checked + true diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCases/TestDatabase.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCases/TestDatabase.cs index 71c527c459d77..596a3c676728b 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCases/TestDatabase.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCases/TestDatabase.cs @@ -43,8 +43,7 @@ public static NPath TestCasesRootDirectory { static IEnumerable AllCases () { - if (_cachedAllCases == null) - _cachedAllCases = CreateCollector () + _cachedAllCases ??= CreateCollector () .Collect () .Where (c => c != null) .OrderBy (c => c.DisplayName) diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs index f84265206067a..d25cf646fc27c 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs @@ -230,11 +230,11 @@ static string FormatBaseOrInterfaceAttributeValue (CustomAttribute attr) StringBuilder builder = new StringBuilder (); builder.Append (attr.ConstructorArguments[0].Value); - builder.Append ("<"); + builder.Append ('<'); bool separator = false; foreach (var caa in (CustomAttributeArgument[]) attr.ConstructorArguments[1].Value) { if (separator) - builder.Append (","); + builder.Append (','); else separator = true; @@ -242,7 +242,7 @@ static string FormatBaseOrInterfaceAttributeValue (CustomAttribute attr) builder.Append (arg.Value); } - builder.Append (">"); + builder.Append ('>'); return builder.ToString (); } @@ -267,7 +267,7 @@ void VerifyFieldKept (FieldDefinition src, FieldDefinition? linked) return; } - if (!object.Equals (src.Constant, linked.Constant)) { + if (!Equals (src.Constant, linked.Constant)) { Assert.True (false, $"Field '{src}' value doesn's match. Expected {src.Constant}, actual {linked.Constant}"); } @@ -466,7 +466,7 @@ static string FormatInstruction (Instruction instr) case FlowControl.Branch: case FlowControl.Cond_Branch: if (instr.Operand is Instruction target) - return $"{instr.OpCode.ToString ()} il_{target.Offset.ToString ("x")}"; + return $"{instr.OpCode} il_{target.Offset:x}"; break; } @@ -474,35 +474,35 @@ static string FormatInstruction (Instruction instr) switch (instr.OpCode.Code) { case Code.Ldc_I4: if (instr.Operand is int ivalue) - return $"{instr.OpCode.ToString ()} 0x{ivalue.ToString ("x")}"; + return $"{instr.OpCode} 0x{ivalue:x}"; throw new NotImplementedException (instr.Operand.GetType ().ToString ()); case Code.Ldc_I4_S: if (instr.Operand is sbyte bvalue) - return $"{instr.OpCode.ToString ()} 0x{bvalue.ToString ("x")}"; + return $"{instr.OpCode} 0x{bvalue:x}"; throw new NotImplementedException (instr.Operand.GetType ().ToString ()); case Code.Ldc_I8: if (instr.Operand is long lvalue) - return $"{instr.OpCode.ToString ()} 0x{lvalue.ToString ("x")}"; + return $"{instr.OpCode} 0x{lvalue:x}"; throw new NotImplementedException (instr.Operand.GetType ().ToString ()); case Code.Ldc_R4: if (instr.Operand is float fvalue) - return $"{instr.OpCode.ToString ()} {fvalue.ToString ()}"; + return $"{instr.OpCode} {fvalue}"; throw new NotImplementedException (instr.Operand.GetType ().ToString ()); case Code.Ldc_R8: if (instr.Operand is double dvalue) - return $"{instr.OpCode.ToString ()} {dvalue.ToString ()}"; + return $"{instr.OpCode} {dvalue}"; throw new NotImplementedException (instr.Operand.GetType ().ToString ()); case Code.Ldstr: if (instr.Operand is string svalue) - return $"{instr.OpCode.ToString ()} '{svalue}'"; + return $"{instr.OpCode} '{svalue}'"; throw new NotImplementedException (instr.Operand.GetType ().ToString ()); @@ -523,7 +523,7 @@ static string FormatInstruction (Instruction instr) } if (operandString != null) - return $"{instr.OpCode.ToString ()} {operandString}"; + return $"{instr.OpCode} {operandString}"; else return instr.OpCode.ToString (); } diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILCompilerDriver.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILCompilerDriver.cs index 5c8c44267edb6..af5f9983e8a12 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILCompilerDriver.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILCompilerDriver.cs @@ -119,7 +119,7 @@ public static void ComputeDefaultOptions (out TargetOS os, out TargetArchitectur } } - private IReadOnlyCollection CreateInitializerList (CompilerTypeSystemContext context, ILCompilerOptions options) + private static IReadOnlyCollection CreateInitializerList (CompilerTypeSystemContext context, ILCompilerOptions options) { List assembliesWithInitalizers = new List (); diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILCompilerTestCaseResult.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILCompilerTestCaseResult.cs index 8fe4bfe8b8e71..20039ead239a3 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILCompilerTestCaseResult.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILCompilerTestCaseResult.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using Mono.Linker.Tests.TestCasesRunner; using Mono.Linker.Tests.Extensions; using Mono.Linker.Tests.TestCases; diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILInputCompiler.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILInputCompiler.cs index 32973f050fa6e..bffa9822c358f 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILInputCompiler.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILInputCompiler.cs @@ -42,7 +42,7 @@ protected virtual void SetupProcess (Process process, CompilerOptions options) process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; } - private string BuildArguments (CompilerOptions options) + private static string BuildArguments (CompilerOptions options) { var args = new StringBuilder (); #if NETCOREAPP diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs index a6adaf187d4c5..bb3665b65afe1 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs @@ -6,24 +6,17 @@ using System.Diagnostics; using System.IO; using System.Linq; -using System.Reflection.Metadata.Ecma335; -using System.Reflection.PortableExecutable; -using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using FluentAssertions; using ILCompiler; -using ILCompiler.Dataflow; using ILCompiler.Logging; -using Mono.Linker.Tests.TestCasesRunner; using Internal.TypeSystem; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Linker.Tests.Cases.Expectations.Assertions; -using Mono.Linker.Tests.Cases.Expectations.Metadata; using Mono.Linker.Tests.Extensions; using Xunit; -using Mono.Linker.Tests.Cases.RequiresCapability; namespace Mono.Linker.Tests.TestCasesRunner { @@ -109,7 +102,7 @@ void VerifyLoggedMessages (AssemblyDefinition original, TestLogWriter logger, bo List loggedMessages = logger.GetLoggedMessages (); List<(IMemberDefinition, CustomAttribute)> expectedNoWarningsAttributes = new List<(IMemberDefinition, CustomAttribute)> (); foreach (var attrProvider in GetAttributeProviders (original)) { - if (attrProvider.ToString () is String mystring && mystring.Contains ("RequiresInCompilerGeneratedCode/SuppressInLambda")) + if (attrProvider.ToString () is string mystring && mystring.Contains ("RequiresInCompilerGeneratedCode/SuppressInLambda")) Debug.WriteLine ("Print"); foreach (var attr in attrProvider.CustomAttributes) { if (!IsProducedByNativeAOT (attr)) @@ -145,7 +138,7 @@ void VerifyLoggedMessages (AssemblyDefinition original, TestLogWriter logger, bo Assert.True ( isLogged (), - $"Expected to not find logged message matching `{unexpectedMessage}`, but found:{Environment.NewLine}{loggedMessage.ToString ()}{Environment.NewLine}Logged messages:{Environment.NewLine}{string.Join (Environment.NewLine, loggedMessages)}"); + $"Expected to not find logged message matching `{unexpectedMessage}`, but found:{Environment.NewLine}{loggedMessage}{Environment.NewLine}Logged messages:{Environment.NewLine}{string.Join (Environment.NewLine, loggedMessages)}"); } } break; @@ -393,13 +386,13 @@ static string ConvertSignatureToIlcFormat (string value) StringBuilder sb = new StringBuilder (); foreach (var part in parts) { if (sb.Length > 0) - sb.Append ("."); + sb.Append ('.'); if (part.EndsWith ('>')) { int i = part.LastIndexOf ('<'); if (i >= 0) { sb.Append (part.Substring (0, i)); - sb.Append ("`"); + sb.Append ('`'); sb.Append (part.Substring (i + 1).Where (c => c == ',').Count () + 1); continue; } diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadataProvider.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadataProvider.cs index cf3a762396379..dc662e4dcf584 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadataProvider.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadataProvider.cs @@ -1,12 +1,10 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.Collections.Generic; using System.IO; using System.Linq; using Mono.Cecil; -using Mono.Linker.Tests.Cases.Expectations.Assertions; using Mono.Linker.Tests.Cases.Expectations.Metadata; using Mono.Linker.Tests.Extensions; using Mono.Linker.Tests.TestCases; diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestInfraMultiFileCompilationModuleGroup.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestInfraMultiFileCompilationModuleGroup.cs index 0ce32dfb4f33a..4c915f1d82999 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestInfraMultiFileCompilationModuleGroup.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestInfraMultiFileCompilationModuleGroup.cs @@ -1,22 +1,19 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using System.Diagnostics; using ILCompiler; -using ILCompiler.DependencyAnalysis; using Internal.TypeSystem; -using Internal.TypeSystem.Ecma; namespace Mono.Linker.Tests.TestCasesRunner { - /// - /// Represents a non-leaf multifile compilation group where types contained in the group are always fully expanded. - /// - public class TestInfraMultiFileSharedCompilationModuleGroup : MultiFileCompilationModuleGroup + /// + /// Represents a non-leaf multifile compilation group where types contained in the group are always fully expanded. + /// + public class TestInfraMultiFileSharedCompilationModuleGroup : MultiFileCompilationModuleGroup { public TestInfraMultiFileSharedCompilationModuleGroup(CompilerTypeSystemContext context, IEnumerable compilationModuleSet) : base(context, compilationModuleSet) @@ -35,7 +32,7 @@ public override bool ShouldPromoteToFullType(TypeDesc type) public override bool PresenceOfEETypeImpliesAllMethodsOnType(TypeDesc type) { - return (type.HasInstantiation || type.IsArray) && ShouldProduceFullVTable(type) && + return (type.HasInstantiation || type.IsArray) && ShouldProduceFullVTable(type) && type.ConvertToCanonForm(CanonicalFormKind.Specific).IsCanonicalSubtype(CanonicalFormKind.Any); } diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestLogWriter.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestLogWriter.cs index c8d4a40a7eabd..0ef6c8fb995a7 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestLogWriter.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestLogWriter.cs @@ -1,12 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using ILCompiler; using ILCompiler.Logging; diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs index 3540250b709f3..b358a33c12b86 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs @@ -4,7 +4,6 @@ using System; using System.Linq; using System.Threading.Tasks; -using Mono.Linker.Tests.TestCasesRunner; using Mono.Cecil; using Mono.Linker.Tests.Extensions; using Mono.Linker.Tests.TestCases; @@ -148,7 +147,7 @@ protected virtual void AddLinkOptions (TestCaseSandbox sandbox, ManagedCompilati builder.ProcessTestInputAssembly (compilationResult.InputAssemblyPath); } - private T GetResultOfTaskThatMakesXUnitAssertions (Task task) + private static T GetResultOfTaskThatMakesXUnitAssertions (Task task) { try { return task.Result; From 567df248ce147b4f931570db4a96d132a6f2e40c Mon Sep 17 00:00:00 2001 From: Tlakollo Date: Tue, 30 Aug 2022 10:20:01 -0700 Subject: [PATCH 02/11] Fix some OSX problems --- .../DependencyAnalysis/ObjectDataBuilder.cs | 2 + .../TypeSystem/IL/Stubs/ComparerIntrinsics.cs | 3 +- .../DependencyAnalysis/NodeFactory.cs | 10 +-- ...estInfraMultiFileCompilationModuleGroup.cs | 64 +++++++++---------- 4 files changed, 37 insertions(+), 42 deletions(-) diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectDataBuilder.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectDataBuilder.cs index 6645f556d0f0e..ff5cee89663c6 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectDataBuilder.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectDataBuilder.cs @@ -213,7 +213,9 @@ private Reservation GetReservationTicket(int size) return ticket; } +#pragma warning disable CA1822 // Mark members as static private int ReturnReservationTicket(Reservation reservation) +#pragma warning restore CA1822 // Mark members as static { #if DEBUG Debug.Assert(_numReservations > 0); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ComparerIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ComparerIntrinsics.cs index db0dfa2cfe2c6..8f6cd67f9a604 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ComparerIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ComparerIntrinsics.cs @@ -225,8 +225,7 @@ private static bool ImplementsInterfaceOfSelf(TypeDesc type, string interfaceNam if (interfaceInstantiation.Length == 1 && interfaceInstantiation[0] == type) { - if (interfaceType == null) - interfaceType = type.Context.SystemModule.GetKnownType("System", interfaceName); + interfaceType ??= interfaceType = type.Context.SystemModule.GetKnownType("System", interfaceName); if (implementedInterface.GetTypeDefinition() == interfaceType) return true; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs index 100a736ba501e..c5e5aef1e4454 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs @@ -931,10 +931,7 @@ public MetadataType ArrayOfTClass { get { - if (_systemArrayOfTClass == null) - { - _systemArrayOfTClass = _context.SystemModule.GetKnownType("System", "Array`1"); - } + _systemArrayOfTClass ??= _systemArrayOfTClass = _context.SystemModule.GetKnownType("System", "Array`1"); return _systemArrayOfTClass; } } @@ -944,10 +941,7 @@ public TypeDesc ArrayOfTEnumeratorType { get { - if (_systemArrayOfTEnumeratorType == null) - { - _systemArrayOfTEnumeratorType = ArrayOfTClass.GetNestedType("ArrayEnumerator"); - } + _systemArrayOfTEnumeratorType ??= _systemArrayOfTEnumeratorType = ArrayOfTClass.GetNestedType("ArrayEnumerator"); return _systemArrayOfTEnumeratorType; } } diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestInfraMultiFileCompilationModuleGroup.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestInfraMultiFileCompilationModuleGroup.cs index 4c915f1d82999..e774cf7c50beb 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestInfraMultiFileCompilationModuleGroup.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestInfraMultiFileCompilationModuleGroup.cs @@ -14,36 +14,36 @@ namespace Mono.Linker.Tests.TestCasesRunner /// Represents a non-leaf multifile compilation group where types contained in the group are always fully expanded. /// public class TestInfraMultiFileSharedCompilationModuleGroup : MultiFileCompilationModuleGroup - { - public TestInfraMultiFileSharedCompilationModuleGroup(CompilerTypeSystemContext context, IEnumerable compilationModuleSet) - : base(context, compilationModuleSet) - { - } - - public override bool ShouldProduceFullVTable(TypeDesc type) - { - return false; - } - - public override bool ShouldPromoteToFullType(TypeDesc type) - { - return ShouldProduceFullVTable(type); - } - - public override bool PresenceOfEETypeImpliesAllMethodsOnType(TypeDesc type) - { - return (type.HasInstantiation || type.IsArray) && ShouldProduceFullVTable(type) && - type.ConvertToCanonForm(CanonicalFormKind.Specific).IsCanonicalSubtype(CanonicalFormKind.Any); - } - - public override bool AllowInstanceMethodOptimization(MethodDesc method) - { - // Both the instance methods and the owning type are homed in a single compilation group - // so if we're able to generate the body, we would also generate the owning type here - // and nowhere else. - Debug.Assert(ContainsMethodBody(method, unboxingStub: false)); - TypeDesc owningType = method.OwningType; - return owningType.IsDefType && !owningType.HasInstantiation && !method.HasInstantiation; - } - } + { + public TestInfraMultiFileSharedCompilationModuleGroup (CompilerTypeSystemContext context, IEnumerable compilationModuleSet) + : base (context, compilationModuleSet) + { + } + + public override bool ShouldProduceFullVTable (TypeDesc type) + { + return false; + } + + public override bool ShouldPromoteToFullType (TypeDesc type) + { + return ShouldProduceFullVTable (type); + } + + public override bool PresenceOfEETypeImpliesAllMethodsOnType (TypeDesc type) + { + return (type.HasInstantiation || type.IsArray) && ShouldProduceFullVTable (type) && + type.ConvertToCanonForm (CanonicalFormKind.Specific).IsCanonicalSubtype (CanonicalFormKind.Any); + } + + public override bool AllowInstanceMethodOptimization (MethodDesc method) + { + // Both the instance methods and the owning type are homed in a single compilation group + // so if we're able to generate the body, we would also generate the owning type here + // and nowhere else. + Debug.Assert (ContainsMethodBody (method, unboxingStub: false)); + TypeDesc owningType = method.OwningType; + return owningType.IsDefType && !owningType.HasInstantiation && !method.HasInstantiation; + } + } } From 5468553e2ef6fb0050bf6c0b891a4cf4f41c0c96 Mon Sep 17 00:00:00 2001 From: Tlakollo Date: Tue, 30 Aug 2022 10:45:09 -0700 Subject: [PATCH 03/11] ModifyThunkGenerator to be able to write CorInfoBase.cs --- .../tools/Common/JitInterface/ThunkGenerator/Program.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/Program.cs b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/Program.cs index 5cd8cb6e66c31..b0d12f06cdc12 100644 --- a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/Program.cs +++ b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/Program.cs @@ -279,14 +279,14 @@ static void WriteManagedThunkInterface(TextWriter tw, IEnumerable namespace Internal.JitInterface { - unsafe partial class CorInfoImpl + internal unsafe partial class CorInfoImpl { "); foreach (FunctionDecl decl in functionData) { tw.WriteLine(" [UnmanagedCallersOnly]"); - tw.Write($" static {decl.ReturnType.UnmanagedTypeName} _{decl.FunctionName}(IntPtr thisHandle, IntPtr* ppException"); + tw.Write($" private static {decl.ReturnType.UnmanagedTypeName} _{decl.FunctionName}(IntPtr thisHandle, IntPtr* ppException"); foreach (Parameter param in decl.Parameters) { tw.Write($", {param.Type.UnmanagedTypeName} {param.Name}"); @@ -344,7 +344,7 @@ unsafe partial class CorInfoImpl int total = functionData.Count(); tw.WriteLine(@" - static IntPtr GetUnmanagedCallbacks() + private static IntPtr GetUnmanagedCallbacks() { void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * " + total + @"); "); From 75bbc193d614249a99eadff2465d6d241a957ae7 Mon Sep 17 00:00:00 2001 From: Tlakollo Date: Tue, 30 Aug 2022 11:45:05 -0700 Subject: [PATCH 04/11] PR feedback --- .../Common/CommandLine/ArgumentSyntax.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/coreclr/tools/Common/CommandLine/ArgumentSyntax.cs b/src/coreclr/tools/Common/CommandLine/ArgumentSyntax.cs index dea88074f329f..976f2a559b1c5 100644 --- a/src/coreclr/tools/Common/CommandLine/ArgumentSyntax.cs +++ b/src/coreclr/tools/Common/CommandLine/ArgumentSyntax.cs @@ -9,7 +9,6 @@ namespace Internal.CommandLine { public sealed partial class ArgumentSyntax { - private const string nameString = "name"; private readonly IEnumerable _arguments; private readonly List _commands = new List(); private readonly List _options = new List(); @@ -108,12 +107,12 @@ public void ReportError(string message) public ArgumentCommand DefineCommand(string name, T value) { if (string.IsNullOrEmpty(name)) - throw new ArgumentException(Strings.NameMissing, nameString); + throw new ArgumentException(Strings.NameMissing, nameof(name)); if (!IsValidName(name)) { var message = string.Format(Strings.CommandNameIsNotValidFmt, name); - throw new ArgumentException(message, nameString); + throw new ArgumentException(message, nameof(name)); } if (_commands.Any(c => string.Equals(c.Name, name, StringComparison.Ordinal))) @@ -144,7 +143,7 @@ public ArgumentCommand DefineCommand(string name, T value) public Argument DefineOption(string name, T defaultValue, Func valueConverter, bool isRequired) { if (string.IsNullOrEmpty(name)) - throw new ArgumentException(Strings.NameMissing, nameString); + throw new ArgumentException(Strings.NameMissing, nameof(name)); if (DefinedParameters.Any()) throw new InvalidOperationException(Strings.OptionsMustBeDefinedBeforeParameters); @@ -179,7 +178,7 @@ public Argument DefineOption(string name, T defaultValue, Func public ArgumentList DefineOptionList(string name, IReadOnlyList defaultValue, Func valueConverter, bool isRequired) { if (string.IsNullOrEmpty(name)) - throw new ArgumentException(Strings.NameMissing, nameString); + throw new ArgumentException(Strings.NameMissing, nameof(name)); if (DefinedParameters.Any()) throw new InvalidOperationException(Strings.OptionsMustBeDefinedBeforeParameters); @@ -214,12 +213,12 @@ public ArgumentList DefineOptionList(string name, IReadOnlyList default public Argument DefineParameter(string name, T defaultValue, Func valueConverter) { if (string.IsNullOrEmpty(name)) - throw new ArgumentException(Strings.NameMissing, nameString); + throw new ArgumentException(Strings.NameMissing, nameof(name)); if (!IsValidName(name)) { var message = string.Format(Strings.ParameterNameIsNotValidFmt, name); - throw new ArgumentException(message, nameString); + throw new ArgumentException(message, nameof(name)); } if (DefinedParameters.Any(p => p.IsList)) @@ -253,12 +252,12 @@ public Argument DefineParameter(string name, T defaultValue, Func DefineParameterList(string name, IReadOnlyList defaultValue, Func valueConverter) { if (string.IsNullOrEmpty(name)) - throw new ArgumentException(Strings.NameMissing, nameString); + throw new ArgumentException(Strings.NameMissing, nameof(name)); if (!IsValidName(name)) { var message = string.Format(Strings.ParameterNameIsNotValidFmt, name); - throw new ArgumentException(message, nameString); + throw new ArgumentException(message, nameof(name)); } if (DefinedParameters.Any(p => p.IsList)) @@ -305,7 +304,7 @@ private IEnumerable ParseOptionNameList(string name) if (!IsValidName(alias)) { var message = string.Format(Strings.OptionNameIsNotValidFmt, alias); - throw new ArgumentException(message, nameString); + throw new ArgumentException(message, nameof(name)); } foreach (var option in DefinedOptions) From 301820c8a919fecf26bb034b6ae99099df7765e0 Mon Sep 17 00:00:00 2001 From: Tlakollo Date: Tue, 30 Aug 2022 12:14:07 -0700 Subject: [PATCH 05/11] Test subset clr.toolstests --- src/coreclr/tools/aot/.editorconfig | 24 ++++++++ .../ArchitectureSpecificFieldLayoutTests.cs | 51 ++++++++-------- .../CastingTests.cs | 2 - .../ConstraintsValidationTest.cs | 2 +- .../GCPointerMapTests.cs | 4 +- .../GenericTypeAndMethodTests.cs | 4 +- .../HashcodeTests.cs | 10 +--- .../InstanceFieldLayoutTests.cs | 6 +- .../InterfacesTests.cs | 4 +- .../StaticFieldLayoutTests.cs | 4 +- .../SyntheticVirtualOverrideTests.cs | 14 ++--- .../TestMetadataFieldLayoutAlgorithm.cs | 2 +- .../TypeNameParsingTests.cs | 27 ++++----- .../UniversalGenericFieldLayoutTests.cs | 16 ++--- .../ValueTypeShapeCharacteristicsTests.cs | 9 ++- .../VirtualFunctionOverrideTests.cs | 12 ++-- .../Extensions/CecilExtensions.cs | 6 +- .../Mono.Linker.Tests/Extensions/NiceIO.cs | 16 ++--- .../TestCases/TestDatabase.cs | 6 +- .../TestCasesRunner/AssemblyChecker.cs | 59 +++++++++---------- .../TestCasesRunner/BaseMetadataProvider.cs | 2 +- .../TestCasesRunner/ILCompilerDriver.cs | 2 +- .../ILCompilerOptionsBuilder.cs | 2 +- .../TestCasesRunner/IgnoreTestException.cs | 2 +- .../TestCasesRunner/ResultChecker.cs | 20 +++---- .../TestCaseAssemblyResolver.cs | 2 +- .../TestCaseCompilationMetadataProvider.cs | 6 +- .../TestCasesRunner/TestCaseCompiler.cs | 10 ++-- .../TestCaseMetadataProvider.cs | 3 +- .../TestCasesRunner/TestCaseSandbox.cs | 5 +- 30 files changed, 172 insertions(+), 160 deletions(-) diff --git a/src/coreclr/tools/aot/.editorconfig b/src/coreclr/tools/aot/.editorconfig index 692dc43eab82a..0190ebce7043f 100644 --- a/src/coreclr/tools/aot/.editorconfig +++ b/src/coreclr/tools/aot/.editorconfig @@ -40,6 +40,9 @@ csharp_style_expression_bodied_properties = true:none csharp_style_expression_bodied_indexers = true:none csharp_style_expression_bodied_accessors = true:none +# IL3000: Avoid accessing Assembly file path when publishing as a single file +dotnet_diagnostic.IL3000.severity = suggestion + # IDE0073: The file header does not match the required text dotnet_diagnostic.IDE0073.severity = none @@ -70,6 +73,15 @@ csharp_style_expression_bodied_properties = true:none csharp_style_expression_bodied_indexers = true:none csharp_style_expression_bodied_accessors = true:none +# IDE0073: The file header does not match the required text +dotnet_diagnostic.IDE0073.severity = none + +# IL3000: Avoid accessing Assembly file path when publishing as a single file +dotnet_diagnostic.IL3000.severity = suggestion + +# IL3002: Avoid calling members marked with 'RequiresAssemblyFilesAttribute' when publishing as a single-file +dotnet_diagnostic.IL3002.severity = suggestion + [Mono.Linker.Tests.Cases/**.cs] indent_style = tab indent_size = 4 @@ -97,6 +109,12 @@ csharp_style_expression_bodied_properties = true:none csharp_style_expression_bodied_indexers = true:none csharp_style_expression_bodied_accessors = true:none +# IL3000: Avoid accessing Assembly file path when publishing as a single file +dotnet_diagnostic.IL3000.severity = suggestion + +# IDE0073: The file header does not match the required text +dotnet_diagnostic.IDE0073.severity = none + [Mono.Linker.Tests.Cases.Expectations/**.cs] indent_style = tab indent_size = 4 @@ -123,3 +141,9 @@ dotnet_sort_system_directives_first = true csharp_style_expression_bodied_properties = true:none csharp_style_expression_bodied_indexers = true:none csharp_style_expression_bodied_accessors = true:none + +# IL3000: Avoid accessing Assembly file path when publishing as a single file +dotnet_diagnostic.IL3000.severity = suggestion + +# IDE0073: The file header does not match the required text +dotnet_diagnostic.IDE0073.severity = none diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ArchitectureSpecificFieldLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ArchitectureSpecificFieldLayoutTests.cs index b474694a91579..38a3595f6c085 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ArchitectureSpecificFieldLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ArchitectureSpecificFieldLayoutTests.cs @@ -10,19 +10,18 @@ namespace TypeSystemTests { public class ArchitectureSpecificFieldLayoutTests { - TestTypeSystemContext _contextX86; - ModuleDesc _testModuleX86; - TestTypeSystemContext _contextX64; - ModuleDesc _testModuleX64; - TestTypeSystemContext _contextX64Windows; - ModuleDesc _testModuleX64Windows; - TestTypeSystemContext _contextX64Linux; - ModuleDesc _testModuleX64Linux; - TestTypeSystemContext _contextARM; - ModuleDesc _testModuleARM; - - TestTypeSystemContext _contextARM64; - ModuleDesc _testModuleARM64; + private TestTypeSystemContext _contextX86; + private ModuleDesc _testModuleX86; + private TestTypeSystemContext _contextX64; + private ModuleDesc _testModuleX64; + private TestTypeSystemContext _contextX64Windows; + private ModuleDesc _testModuleX64Windows; + private TestTypeSystemContext _contextX64Linux; + private ModuleDesc _testModuleX64Linux; + private TestTypeSystemContext _contextARM; + private ModuleDesc _testModuleARM; + private TestTypeSystemContext _contextARM64; + private ModuleDesc _testModuleARM64; public ArchitectureSpecificFieldLayoutTests() { @@ -339,20 +338,20 @@ public void TestAlignmentBehavior_IntShortEnumStructAuto() Assert.Equal(0x4, tX86.InstanceByteAlignment.AsInt); Assert.Equal(0x10, tX64.InstanceByteCountUnaligned.AsInt); - Assert.Equal(0xC, tARM.InstanceByteCountUnaligned.AsInt); - Assert.Equal(0xC, tX86.InstanceByteCountUnaligned.AsInt); + Assert.Equal(0xC, tARM.InstanceByteCountUnaligned.AsInt); + Assert.Equal(0xC, tX86.InstanceByteCountUnaligned.AsInt); Assert.Equal(0x10, tX64.InstanceByteCount.AsInt); - Assert.Equal(0xC, tARM.InstanceByteCount.AsInt); - Assert.Equal(0xC, tX86.InstanceByteCount.AsInt); + Assert.Equal(0xC, tARM.InstanceByteCount.AsInt); + Assert.Equal(0xC, tX86.InstanceByteCount.AsInt); Assert.Equal(0x8, tX64.InstanceFieldAlignment.AsInt); Assert.Equal(0x4, tARM.InstanceFieldAlignment.AsInt); Assert.Equal(0x4, tX86.InstanceFieldAlignment.AsInt); Assert.Equal(0x10, tX64.InstanceFieldSize.AsInt); - Assert.Equal(0xC, tARM.InstanceFieldSize.AsInt); - Assert.Equal(0xC, tX86.InstanceFieldSize.AsInt); + Assert.Equal(0xC, tARM.InstanceFieldSize.AsInt); + Assert.Equal(0xC, tX86.InstanceFieldSize.AsInt); Assert.Equal(0x0, tX64.GetField("_1").Offset.AsInt); Assert.Equal(0x0, tARM.GetField("_1").Offset.AsInt); @@ -463,13 +462,13 @@ public void TestAlignmentBehavior_StructStructByte_StructByteAuto() } [Theory] - [InlineData("StructStructByte_StructByteAuto", new int[]{1,1,1}, new int[]{2,2,2})] - [InlineData("StructStructByte_Struct2BytesAuto", new int[]{2,2,2}, new int[]{4,4,4})] - [InlineData("StructStructByte_Struct3BytesAuto", new int[]{4,4,4}, new int[]{8,8,8})] - [InlineData("StructStructByte_Struct4BytesAuto", new int[]{4,4,4}, new int[]{8,8,8})] - [InlineData("StructStructByte_Struct5BytesAuto", new int[]{8,4,4}, new int[]{16,12,12})] - [InlineData("StructStructByte_Struct8BytesAuto", new int[]{8,4,4}, new int[]{16,12,12})] - [InlineData("StructStructByte_Struct9BytesAuto", new int[]{8,4,4}, new int[]{24,16,16})] + [InlineData("StructStructByte_StructByteAuto", new int[] { 1, 1, 1 }, new int[] { 2, 2, 2 })] + [InlineData("StructStructByte_Struct2BytesAuto", new int[] { 2, 2, 2 }, new int[] { 4, 4, 4 })] + [InlineData("StructStructByte_Struct3BytesAuto", new int[] { 4, 4, 4 }, new int[] { 8, 8, 8 })] + [InlineData("StructStructByte_Struct4BytesAuto", new int[] { 4, 4, 4 }, new int[] { 8, 8, 8 })] + [InlineData("StructStructByte_Struct5BytesAuto", new int[] { 8, 4, 4 }, new int[] { 16, 12, 12 })] + [InlineData("StructStructByte_Struct8BytesAuto", new int[] { 8, 4, 4 }, new int[] { 16, 12, 12 })] + [InlineData("StructStructByte_Struct9BytesAuto", new int[] { 8, 4, 4 }, new int[] { 24, 16, 16 })] public void TestAlignmentBehavior_AutoAlignmentRules(string wrapperType, int[] alignment, int[] size) { string _namespace = "Sequential"; diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CastingTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CastingTests.cs index 7ba6109f6405a..fdf12612f4003 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CastingTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CastingTests.cs @@ -148,8 +148,6 @@ public void TestGenericParameterCasting() TypeDesc valueTypeType = _context.GetWellKnownType(WellKnownType.ValueType); TypeDesc iFooType = _testModule.GetType("Casting", "IFoo"); TypeDesc classImplementingIFooType = _testModule.GetType("Casting", "ClassImplementingIFoo"); - TypeDesc classImplementingIFooIndirectlyType = - _testModule.GetType("Casting", "ClassImplementingIFooIndirectly"); Assert.True(paramWithNoConstraint.CanCastTo(objectType)); Assert.False(paramWithNoConstraint.CanCastTo(valueTypeType)); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ConstraintsValidationTest.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ConstraintsValidationTest.cs index a263233a5eef5..555504eecad05 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ConstraintsValidationTest.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ConstraintsValidationTest.cs @@ -178,7 +178,7 @@ public void TestTypeConstraints() } // SimpleTypeConstraint and DoubleSimpleTypeConstraint - foreach(var genType in new MetadataType[] { _simpleTypeConstraintType , _doubleSimpleTypeConstraintType }) + foreach(var genType in new MetadataType[] { _simpleTypeConstraintType, _doubleSimpleTypeConstraintType }) { instantiatedType = genType.MakeInstantiatedType(_arg1Type); Assert.True(instantiatedType.CheckConstraints()); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GCPointerMapTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GCPointerMapTests.cs index 51578a171105a..de3fc50334146 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GCPointerMapTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GCPointerMapTests.cs @@ -9,8 +9,8 @@ namespace TypeSystemTests { public partial class GCPointerMapTests { - TestTypeSystemContext _context; - ModuleDesc _testModule; + private TestTypeSystemContext _context; + private ModuleDesc _testModule; public GCPointerMapTests() { diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GenericTypeAndMethodTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GenericTypeAndMethodTests.cs index c9224fa7d9dbd..73233b17df43f 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GenericTypeAndMethodTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GenericTypeAndMethodTests.cs @@ -113,7 +113,7 @@ public void TestMethodLookup() { MetadataType t = _testModule.GetType("GenericTypes", "GenericClass`1").MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32)); - MethodSignature sig = new MethodSignature(MethodSignatureFlags.None, 0, _context.GetSignatureVariable(0, false), new TypeDesc[0] { }); + MethodSignature sig = new MethodSignature(MethodSignatureFlags.None, 0, _context.GetSignatureVariable(0, false), System.Array.Empty()); MethodDesc fooMethod = t.GetMethod("Foo", sig); Assert.NotNull(fooMethod); } @@ -222,8 +222,6 @@ public void TestConstructedMethodAdjustment() MetadataType genericOpenType = _testModule.GetType("GenericTypes", "TwoParamGenericClass`2"); MetadataType nonGenericType = _testModule.GetType("GenericTypes", "NonGenericClass"); - MethodDesc nonGenericOnGeneric = genericOpenType.GetMethod("NonGenericFunction", null); - MethodDesc genericOnGeneric = genericOpenType.GetMethod("GenericFunction", null); MethodDesc genericOnNonGeneric = nonGenericType.GetMethod("GenericFunction", null); InstantiatedType genericIntString = genericOpenType.MakeInstantiatedType(intType, stringType); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/HashcodeTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/HashcodeTests.cs index a9451752da9b9..a57216950e0b7 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/HashcodeTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/HashcodeTests.cs @@ -12,8 +12,8 @@ namespace TypeSystemTests { public class HashcodeTests { - TestTypeSystemContext _context; - ModuleDesc _testModule; + private TestTypeSystemContext _context; + private ModuleDesc _testModule; public HashcodeTests() { @@ -27,7 +27,6 @@ public HashcodeTests() [Fact] public void TestMultidimensionalArrays() { - DefType systemArrayType = _context.GetWellKnownType(WellKnownType.Array); TypeDesc objectType = _context.GetWellKnownType(WellKnownType.Object); ArrayType objectMDArrayRank1 = _context.GetArrayType(objectType, 1); @@ -42,8 +41,6 @@ public void TestMultidimensionalArrays() [Fact] public void TestSingleDimensionalArrays() { - DefType systemArrayType = _context.GetWellKnownType(WellKnownType.Array); - TypeDesc objectType = _context.GetWellKnownType(WellKnownType.Object); ArrayType objectArray = _context.GetArrayType(objectType); @@ -54,7 +51,6 @@ public void TestSingleDimensionalArrays() [Fact] public void TestNonGenericTypes() { - DefType systemArrayType = _context.GetWellKnownType(WellKnownType.Array); MetadataType nonNestedType = (MetadataType)_testModule.GetType("Hashcode", "NonNestedType"); TypeDesc nestedType = nonNestedType.GetNestedType("NestedType"); @@ -67,7 +63,7 @@ public void TestNonGenericTypes() } [Fact] - void TestGenericTypes() + public void TestGenericTypes() { MetadataType ilistType = (MetadataType)_testModule.GetType("System.Collections.Generic", "IList`1"); DefType systemArrayType = _context.GetWellKnownType(WellKnownType.Array); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InstanceFieldLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InstanceFieldLayoutTests.cs index 083a4e65af384..e846cbfe31af9 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InstanceFieldLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InstanceFieldLayoutTests.cs @@ -11,9 +11,9 @@ namespace TypeSystemTests { public class InstanceFieldLayoutTests { - TestTypeSystemContext _context; - ModuleDesc _testModule; - ModuleDesc _ilTestModule; + private TestTypeSystemContext _context; + private ModuleDesc _testModule; + private ModuleDesc _ilTestModule; public InstanceFieldLayoutTests() { diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InterfacesTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InterfacesTests.cs index 8cbadda3948f1..03377d5fb0361 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InterfacesTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InterfacesTests.cs @@ -10,8 +10,8 @@ namespace TypeSystemTests { public class InterfacesTests { - TestTypeSystemContext _context; - ModuleDesc _testModule; + private TestTypeSystemContext _context; + private ModuleDesc _testModule; public InterfacesTests() { diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/StaticFieldLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/StaticFieldLayoutTests.cs index 2133c7429cc1b..e5855d624672c 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/StaticFieldLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/StaticFieldLayoutTests.cs @@ -14,8 +14,8 @@ namespace TypeSystemTests { public class StaticFieldLayoutTests { - TestTypeSystemContext _context; - ModuleDesc _testModule; + private TestTypeSystemContext _context; + private ModuleDesc _testModule; public StaticFieldLayoutTests() { diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs index 25be615490fbc..b23806c7072f8 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs @@ -14,8 +14,8 @@ namespace TypeSystemTests { public partial class SyntheticVirtualOverrideTests { - TestTypeSystemContext _context; - ModuleDesc _testModule; + private TestTypeSystemContext _context; + private ModuleDesc _testModule; public SyntheticVirtualOverrideTests() { @@ -50,7 +50,7 @@ public void TestStructEqualsAndGetHashCode() Assert.All(virtualSlots, s => { Assert.True(s.OwningType.IsObject); }); Assert.Equal(4, virtualSlots.Count); - List vtable = virtualSlots.Select(s => t.FindVirtualFunctionTargetMethodOnObjectType(s)).ToList(); + List vtable = virtualSlots.Select(t.FindVirtualFunctionTargetMethodOnObjectType).ToList(); Assert.Contains(vtable, m => m.Name == "Equals" && m.OwningType == t); Assert.Contains(vtable, m => m.Name == "GetHashCode" && m.OwningType == t); @@ -73,7 +73,7 @@ public void TestUnoverriddenSyntheticEqualsAndGetHashCode() Assert.All(virtualSlots, s => { Assert.True(s.OwningType.IsObject); }); Assert.Equal(4, virtualSlots.Count); - List vtable = virtualSlots.Select(s => t.FindVirtualFunctionTargetMethodOnObjectType(s)).ToList(); + List vtable = virtualSlots.Select(t.FindVirtualFunctionTargetMethodOnObjectType).ToList(); Assert.Contains(vtable, m => m.Name == "Equals" && m.OwningType == baseType); Assert.Contains(vtable, m => m.Name == "GetHashCode" && m.OwningType == baseType); @@ -96,7 +96,7 @@ public void TestOverriddenSyntheticEqualsAndGetHashCode() Assert.All(virtualSlots, s => { Assert.True(s.OwningType.IsObject); }); Assert.Equal(4, virtualSlots.Count); - List vtable = virtualSlots.Select(s => t.FindVirtualFunctionTargetMethodOnObjectType(s)).ToList(); + List vtable = virtualSlots.Select(t.FindVirtualFunctionTargetMethodOnObjectType).ToList(); Assert.Contains(vtable, m => m.Name == "Equals" && m.OwningType == t); Assert.Contains(vtable, m => m.Name == "GetHashCode" && m.OwningType == t); @@ -104,7 +104,7 @@ public void TestOverriddenSyntheticEqualsAndGetHashCode() Assert.Contains(vtable, m => m.Name == "ToString" && m.OwningType.IsObject); } - private class SyntheticVirtualOverrideTypeSystemContext : TestTypeSystemContext + private sealed class SyntheticVirtualOverrideTypeSystemContext : TestTypeSystemContext { private Dictionary _getHashCodeMethods = new Dictionary(); private Dictionary _equalsMethods = new Dictionary(); @@ -170,7 +170,7 @@ protected override IEnumerable GetAllVirtualMethods(TypeDesc type) } } - private partial class SyntheticMethod : MethodDesc + private sealed partial class SyntheticMethod : MethodDesc { private TypeDesc _owningType; private MethodSignature _signature; diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TestMetadataFieldLayoutAlgorithm.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TestMetadataFieldLayoutAlgorithm.cs index 8e7b749fa274f..da423b43cb280 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TestMetadataFieldLayoutAlgorithm.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TestMetadataFieldLayoutAlgorithm.cs @@ -5,7 +5,7 @@ namespace TypeSystemTests { - class TestMetadataFieldLayoutAlgorithm : MetadataFieldLayoutAlgorithm + internal sealed class TestMetadataFieldLayoutAlgorithm : MetadataFieldLayoutAlgorithm { protected override void PrepareRuntimeSpecificStaticFieldLayout(TypeSystemContext context, ref ComputedStaticFieldLayout layout) { diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeNameParsingTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeNameParsingTests.cs index c4549db3d9473..a426730a784bb 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeNameParsingTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeNameParsingTests.cs @@ -11,22 +11,17 @@ namespace TypeSystemTests { public class TypeNameParsingTests { - TestTypeSystemContext _context; - ModuleDesc _testModule; - - string _coreAssemblyQualifier; - - MetadataType _simpleType; - MetadataType _nestedType; - MetadataType _nestedTwiceType; - - MetadataType _genericType; - MetadataType _nestedNongenericType; - MetadataType _nestedGenericType; - - MetadataType _veryGenericType; - - MetadataType _structType; + private TestTypeSystemContext _context; + private ModuleDesc _testModule; + private string _coreAssemblyQualifier; + private MetadataType _simpleType; + private MetadataType _nestedType; + private MetadataType _nestedTwiceType; + private MetadataType _genericType; + private MetadataType _nestedNongenericType; + private MetadataType _nestedGenericType; + private MetadataType _veryGenericType; + private MetadataType _structType; public TypeNameParsingTests() { diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/UniversalGenericFieldLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/UniversalGenericFieldLayoutTests.cs index 2e42e7bac0d46..338f7d8d75b90 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/UniversalGenericFieldLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/UniversalGenericFieldLayoutTests.cs @@ -12,12 +12,12 @@ namespace TypeSystemTests { public class UniversalGenericFieldLayoutTests { - TestTypeSystemContext _contextX86; - ModuleDesc _testModuleX86; - TestTypeSystemContext _contextX64; - ModuleDesc _testModuleX64; - TestTypeSystemContext _contextARM; - ModuleDesc _testModuleARM; + private TestTypeSystemContext _contextX86; + private ModuleDesc _testModuleX86; + private TestTypeSystemContext _contextX64; + private ModuleDesc _testModuleX64; + private TestTypeSystemContext _contextARM; + private ModuleDesc _testModuleARM; public UniversalGenericFieldLayoutTests() { @@ -327,6 +327,7 @@ public void TestIndeterminateNestedStructField() InstantiatedType genOfIntNestedInt; InstantiatedType genOfLongNestedInt; +#pragma warning disable IDE0059 // Unnecessary assignment of a value TestIndeterminatedNestedStructFieldPerContext(_contextX64, _testModuleX64, out genOfIntNestedInt, out genOfLongNestedInt); Assert.Equal(new LayoutInt(8), genOfLongNestedInt.InstanceByteAlignment); Assert.Equal(new LayoutInt(8), genOfLongNestedInt.InstanceByteAlignment); @@ -334,6 +335,7 @@ public void TestIndeterminateNestedStructField() Assert.Equal(new LayoutInt(4), genOfLongNestedInt.InstanceByteAlignment); Assert.Equal(new LayoutInt(4), genOfLongNestedInt.InstanceByteAlignment); TestIndeterminatedNestedStructFieldPerContext(_contextARM, _testModuleARM, out genOfIntNestedInt, out genOfLongNestedInt); +#pragma warning restore IDE0059 // Unnecessary assignment of a value Assert.Equal(LayoutInt.Indeterminate, genOfLongNestedInt.InstanceByteAlignment); Assert.Equal(LayoutInt.Indeterminate, genOfLongNestedInt.InstanceByteAlignment); } @@ -347,7 +349,7 @@ private static void AssertClassIndeterminateSize(TypeSystemContext context, Meta Assert.Equal(LayoutInt.Indeterminate, type.InstanceByteCountUnaligned); } - private void CommonClassLayoutTestBits(ModuleDesc testModule, + private static void CommonClassLayoutTestBits(ModuleDesc testModule, TypeSystemContext context, LayoutInt expectedIndeterminateByteAlignment, out InstantiatedType genOfIU, diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ValueTypeShapeCharacteristicsTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ValueTypeShapeCharacteristicsTests.cs index 64ffa38b96353..b0f60dca9acd0 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ValueTypeShapeCharacteristicsTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ValueTypeShapeCharacteristicsTests.cs @@ -9,11 +9,10 @@ namespace TypeSystemTests { public class ValueTypeShapeCharacteristicsTests { - const ValueTypeShapeCharacteristics Float32Aggregate = ValueTypeShapeCharacteristics.Float32Aggregate; - const ValueTypeShapeCharacteristics Float64Aggregate = ValueTypeShapeCharacteristics.Float64Aggregate; - - TestTypeSystemContext _context; - ModuleDesc _testModule; + private const ValueTypeShapeCharacteristics Float32Aggregate = ValueTypeShapeCharacteristics.Float32Aggregate; + private const ValueTypeShapeCharacteristics Float64Aggregate = ValueTypeShapeCharacteristics.Float64Aggregate; + private TestTypeSystemContext _context; + private ModuleDesc _testModule; public ValueTypeShapeCharacteristicsTests() { diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs index 1053335237379..e228993296ff5 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs @@ -12,10 +12,10 @@ namespace TypeSystemTests { public class VirtualFunctionOverrideTests { - TestTypeSystemContext _context; - ModuleDesc _testModule; - DefType _stringType; - DefType _voidType; + private TestTypeSystemContext _context; + private ModuleDesc _testModule; + private DefType _stringType; + private DefType _voidType; public VirtualFunctionOverrideTests() { @@ -103,7 +103,7 @@ public void TestFinalizeOverrideChecking() { MetadataType classWithFinalizer = _testModule.GetType("VirtualFunctionOverride", "ClassWithFinalizer"); DefType objectType = _testModule.Context.GetWellKnownType(WellKnownType.Object); - MethodDesc finalizeMethod = objectType.GetMethod("Finalize", new MethodSignature(MethodSignatureFlags.None, 0, _voidType, new TypeDesc[] { })); + MethodDesc finalizeMethod = objectType.GetMethod("Finalize", new MethodSignature(MethodSignatureFlags.None, 0, _voidType, Array.Empty())); MethodDesc actualFinalizer = classWithFinalizer.FindVirtualFunctionTargetMethodOnObjectType(finalizeMethod); Assert.NotNull(actualFinalizer); @@ -192,7 +192,6 @@ public void TestGenericsClassOverrideOfMethodWhereMethodHasBeenMovedFromTheTypeW var bang0Type = _context.GetSignatureVariable(0, false); var bang1Type = _context.GetSignatureVariable(1, false); var bang2Type = _context.GetSignatureVariable(2, false); - var bang3Type = _context.GetSignatureVariable(3, false); MethodSignature sigBang0Bang1 = new MethodSignature(0, 0, stringType, new TypeDesc[] { bang0Type, bang1Type }); MethodDesc baseMethod0_1 = baseType.GetMethod("Method", sigBang0Bang1); @@ -200,7 +199,6 @@ public void TestGenericsClassOverrideOfMethodWhereMethodHasBeenMovedFromTheTypeW MethodDesc virtualMethodBang0Bang1 = algo.FindVirtualFunctionTargetMethodOnObjectType(baseMethod0_1, myDerivedType); Assert.Equal(virtualMethodBang0Bang1.OwningType, baseType); - MethodSignature sigBang2Bang3 = new MethodSignature(0, 0, stringType, new TypeDesc[] { bang2Type, bang3Type }); MethodDesc baseMethod2_3 = null; // BaseMethod(!2,!3) has custom modifiers in its signature, and thus the sig is difficult to write up by hand. Just search for // it in an ad hoc manner diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/CecilExtensions.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/CecilExtensions.cs index 7efcb271461db..763cec9c4c776 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/CecilExtensions.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/CecilExtensions.cs @@ -118,7 +118,9 @@ public static bool DerivesFrom (this TypeDefinition type, string baseTypeName) public static PropertyDefinition GetPropertyDefinition (this MethodDefinition method) { if (!method.IsSetter && !method.IsGetter) +#pragma warning disable CA2208 // Instantiate argument exceptions correctly throw new ArgumentException (); +#pragma warning restore CA2208 // Instantiate argument exceptions correctly var propertyName = method.Name.Substring (4); return method.DeclaringType.Properties.First (p => p.Name == propertyName); @@ -328,7 +330,7 @@ public static void PrependGenericParameters (IList genericPara sb.Insert (0, '<'); } - static void PrependGenericArguments (Stack genericArguments, int argumentsToTake, StringBuilder sb) + private static void PrependGenericArguments (Stack genericArguments, int argumentsToTake, StringBuilder sb) { sb.Insert (0, '>').Insert (0, genericArguments.Pop ().GetDisplayNameWithoutNamespace ().ToString ()); while (--argumentsToTake > 0) @@ -337,7 +339,7 @@ static void PrependGenericArguments (Stack genericArguments, int sb.Insert (0, '<'); } - static void AppendArrayType (ArrayType arrayType, StringBuilder sb) + private static void AppendArrayType (ArrayType arrayType, StringBuilder sb) { void parseArrayDimensions (ArrayType at) { diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/NiceIO.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/NiceIO.cs index c2b1ff6eaf1a9..cb2f8e78c15e8 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/NiceIO.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/NiceIO.cs @@ -48,13 +48,15 @@ public class NPath : IEquatable, IComparable public NPath (string path) { if (path == null) +#pragma warning disable CA2208 // Instantiate argument exceptions correctly throw new ArgumentNullException (); +#pragma warning restore CA2208 // Instantiate argument exceptions correctly path = ParseDriveLetter (path, out _driveLetter); if (path == "/") { _isRelative = false; - _elements = new string[] { }; + _elements = Array.Empty (); } else { var split = path.Split ('/', '\\'); @@ -294,7 +296,7 @@ public static implicit operator string (NPath path) return path.ToString (); } - static char Slash (SlashMode slashMode) + private static char Slash (SlashMode slashMode) { return slashMode switch { SlashMode.Backward => '\\', @@ -379,8 +381,8 @@ public int CompareTo (object? obj) public bool HasExtension (params string[] extensions) { - var extensionWithDotLower = ExtensionWithDot.ToLower (); - return extensions.Any (e => WithDot (e).ToLower () == extensionWithDotLower); + var extensionWithDotLower = ExtensionWithDot.ToLowerInvariant (); + return extensions.Any (e => WithDot (e).ToLowerInvariant () == extensionWithDotLower); } private static string WithDot (string extension) @@ -439,7 +441,7 @@ public NPath CreateFile () ThrowIfRelative (); ThrowIfRoot (); EnsureParentDirectoryExists (); - File.WriteAllBytes (ToString (), new byte[0]); + File.WriteAllBytes (ToString (), Array.Empty ()); return this; } @@ -514,7 +516,7 @@ public NPath MakeAbsolute () return CurrentDirectory.Combine (this); } - NPath? CopyWithDeterminedDestination (NPath absoluteDestination, Func fileFilter) + private NPath? CopyWithDeterminedDestination (NPath absoluteDestination, Func fileFilter) { if (absoluteDestination.IsRelative) throw new ArgumentException ("absoluteDestination must be absolute"); @@ -792,7 +794,7 @@ public IEnumerable MoveFiles (NPath destination, bool recurse, Func file.Move (destination.Combine (file.RelativeTo (this)))).ToArray (); } - static bool AlwaysTrue (NPath p) + private static bool AlwaysTrue (NPath p) { return true; } diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCases/TestDatabase.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCases/TestDatabase.cs index 596a3c676728b..dc580c55f081c 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCases/TestDatabase.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCases/TestDatabase.cs @@ -41,7 +41,7 @@ public static NPath TestCasesRootDirectory { } } - static IEnumerable AllCases () + private static IEnumerable AllCases () { _cachedAllCases ??= CreateCollector () .Collect () @@ -57,7 +57,7 @@ static IEnumerable AllCases () return AllCases ().FirstOrDefault (c => c.Name == name); } - static IEnumerable TestNamesBySuiteName (string suiteName) + private static IEnumerable TestNamesBySuiteName (string suiteName) { return AllCases () .Where (c => c.TestSuiteDirectory.FileName == suiteName) @@ -66,7 +66,7 @@ static IEnumerable TestNamesBySuiteName (string suiteName) .Select (c => new object[] { c }); } - static void GetDirectoryPaths (out string rootSourceDirectory, out string testCaseAssemblyPath) + private static void GetDirectoryPaths (out string rootSourceDirectory, out string testCaseAssemblyPath) { rootSourceDirectory = Path.GetFullPath (Path.Combine (PathUtilities.GetTestsSourceRootDirectory (), "Mono.Linker.Tests.Cases")); testCaseAssemblyPath = PathUtilities.GetTestAssemblyPath ("Mono.Linker.Tests.Cases"); diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs index d25cf646fc27c..1e2836d080e28 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs @@ -16,13 +16,12 @@ namespace Mono.Linker.Tests.TestCasesRunner { public class AssemblyChecker { - readonly AssemblyDefinition originalAssembly, linkedAssembly; - - HashSet linkedMembers; - readonly HashSet verifiedGeneratedFields = new HashSet (); - readonly HashSet verifiedEventMethods = new HashSet (); - readonly HashSet verifiedGeneratedTypes = new HashSet (); - bool checkNames; + private readonly AssemblyDefinition originalAssembly, linkedAssembly; + private HashSet linkedMembers; + private readonly HashSet verifiedGeneratedFields = new HashSet (); + private readonly HashSet verifiedEventMethods = new HashSet (); + private readonly HashSet verifiedGeneratedTypes = new HashSet (); + private bool checkNames; public AssemblyChecker (AssemblyDefinition original, AssemblyDefinition linked) { @@ -188,7 +187,7 @@ protected virtual void VerifyTypeDefinitionKept (TypeDefinition original, TypeDe } } - void VerifyBaseType (TypeDefinition src, TypeDefinition linked) + private void VerifyBaseType (TypeDefinition src, TypeDefinition linked) { string expectedBaseName; var expectedBaseGenericAttr = src.CustomAttributes.FirstOrDefault (w => w.AttributeType.Name == nameof (KeptBaseTypeAttribute) && w.ConstructorArguments.Count > 1); @@ -204,7 +203,7 @@ void VerifyBaseType (TypeDefinition src, TypeDefinition linked) } } - void VerifyInterfaces (TypeDefinition src, TypeDefinition linked) + private void VerifyInterfaces (TypeDefinition src, TypeDefinition linked) { var expectedInterfaces = new HashSet (src.CustomAttributes .Where (w => w.AttributeType.Name == nameof (KeptInterfaceAttribute)) @@ -223,7 +222,7 @@ void VerifyInterfaces (TypeDefinition src, TypeDefinition linked) } } - static string FormatBaseOrInterfaceAttributeValue (CustomAttribute attr) + private static string FormatBaseOrInterfaceAttributeValue (CustomAttribute attr) { if (attr.ConstructorArguments.Count == 1) return attr.ConstructorArguments[0].Value.ToString ()!; @@ -246,7 +245,7 @@ static string FormatBaseOrInterfaceAttributeValue (CustomAttribute attr) return builder.ToString (); } - void VerifyField (FieldDefinition src, FieldDefinition? linked) + private void VerifyField (FieldDefinition src, FieldDefinition? linked) { bool expectedKept = ShouldBeKept (src); @@ -260,7 +259,7 @@ void VerifyField (FieldDefinition src, FieldDefinition? linked) VerifyFieldKept (src, linked); } - void VerifyFieldKept (FieldDefinition src, FieldDefinition? linked) + private void VerifyFieldKept (FieldDefinition src, FieldDefinition? linked) { if (linked == null) { Assert.True (false, $"Field `{src}' should have been kept"); @@ -275,7 +274,7 @@ void VerifyFieldKept (FieldDefinition src, FieldDefinition? linked) VerifyCustomAttributes (src, linked); } - void VerifyProperty (PropertyDefinition src, PropertyDefinition? linked, TypeDefinition linkedType) + private void VerifyProperty (PropertyDefinition src, PropertyDefinition? linked, TypeDefinition linkedType) { VerifyMemberBackingField (src, linkedType); @@ -301,7 +300,7 @@ void VerifyProperty (PropertyDefinition src, PropertyDefinition? linked, TypeDef VerifyCustomAttributes (src, linked); } - void VerifyEvent (EventDefinition src, EventDefinition? linked, TypeDefinition linkedType) + private void VerifyEvent (EventDefinition src, EventDefinition? linked, TypeDefinition linkedType) { VerifyMemberBackingField (src, linkedType); @@ -335,14 +334,13 @@ void VerifyEvent (EventDefinition src, EventDefinition? linked, TypeDefinition l VerifyCustomAttributes (src, linked); } - void VerifyMethod (MethodDefinition src, MethodDefinition? linked) + private void VerifyMethod (MethodDefinition src, MethodDefinition? linked) { bool expectedKept = ShouldMethodBeKept (src); VerifyMethodInternal (src, linked, expectedKept); } - - void VerifyMethodInternal (MethodDefinition src, MethodDefinition? linked, bool expectedKept) + private void VerifyMethodInternal (MethodDefinition src, MethodDefinition? linked, bool expectedKept) { if (!expectedKept) { if (linked != null) @@ -354,7 +352,7 @@ void VerifyMethodInternal (MethodDefinition src, MethodDefinition? linked, bool VerifyMethodKept (src, linked); } - void VerifyMemberBackingField (IMemberDefinition src, TypeDefinition linkedType) + private void VerifyMemberBackingField (IMemberDefinition src, TypeDefinition linkedType) { var keptBackingFieldAttribute = src.CustomAttributes.FirstOrDefault (attr => attr.AttributeType.Name == nameof (KeptBackingFieldAttribute)); if (keptBackingFieldAttribute == null) @@ -460,7 +458,7 @@ void Append (string text) => result.Add ((null, text)); } - static string FormatInstruction (Instruction instr) + private static string FormatInstruction (Instruction instr) { switch (instr.OpCode.FlowControl) { case FlowControl.Branch: @@ -529,7 +527,8 @@ static string FormatInstruction (Instruction instr) } } } - static void VerifyLocals (MethodDefinition src, MethodDefinition linked) + + private static void VerifyLocals (MethodDefinition src, MethodDefinition linked) { VerifyBodyProperties ( src, @@ -560,7 +559,7 @@ public static void VerifyBodyProperties (MethodDefinition src, MethodDefinition } } - void VerifyReferences (AssemblyDefinition original, AssemblyDefinition linked) + private void VerifyReferences (AssemblyDefinition original, AssemblyDefinition linked) { var expected = original.MainModule.AllDefinedTypes () .SelectMany (t => GetCustomAttributeCtorValues (t, nameof (KeptReferenceAttribute))) @@ -586,7 +585,7 @@ void VerifyReferences (AssemblyDefinition original, AssemblyDefinition linked) actual.Should ().BeEquivalentTo (expected); } - string? ReduceAssemblyFileNameOrNameToNameOnly (string? fileNameOrAssemblyName) + private string? ReduceAssemblyFileNameOrNameToNameOnly (string? fileNameOrAssemblyName) { if (fileNameOrAssemblyName == null) return null; @@ -598,7 +597,7 @@ void VerifyReferences (AssemblyDefinition original, AssemblyDefinition linked) return fileNameOrAssemblyName; } - void VerifyResources (AssemblyDefinition original, AssemblyDefinition linked) + private void VerifyResources (AssemblyDefinition original, AssemblyDefinition linked) { var expectedResourceNames = original.MainModule.AllDefinedTypes () .SelectMany (t => GetCustomAttributeCtorValues (t, nameof (KeptResourceAttribute))) @@ -620,7 +619,7 @@ void VerifyResources (AssemblyDefinition original, AssemblyDefinition linked) } } - void VerifyExportedTypes (AssemblyDefinition original, AssemblyDefinition linked) + private void VerifyExportedTypes (AssemblyDefinition original, AssemblyDefinition linked) { var expectedTypes = original.MainModule.AllDefinedTypes () .SelectMany (t => GetCustomAttributeCtorValues (t, nameof (KeptExportedTypeAttribute)).Select (l => l?.FullName ?? "")).ToArray (); @@ -731,7 +730,7 @@ protected virtual void VerifyArrayInitializers (MethodDefinition src, MethodDefi } } - void VerifyInitializerField (FieldDefinition src, FieldDefinition? linked) + private void VerifyInitializerField (FieldDefinition src, FieldDefinition? linked) { VerifyFieldKept (src, linked); verifiedGeneratedFields.Add (linked!.FullName); @@ -742,7 +741,7 @@ void VerifyInitializerField (FieldDefinition src, FieldDefinition? linked) verifiedGeneratedTypes.Add (linked.DeclaringType.FullName); } - static bool IsLdtokenOnPrivateImplementationDetails (TypeDefinition privateImplementationDetails, Instruction instruction) + private static bool IsLdtokenOnPrivateImplementationDetails (TypeDefinition privateImplementationDetails, Instruction instruction) { if (instruction.OpCode.Code == Code.Ldtoken && instruction.Operand is FieldReference field) { return field.DeclaringType.Resolve () == privateImplementationDetails; @@ -809,7 +808,7 @@ protected virtual IEnumerable FilterLinkedSecurityAttributes (ISecurityD .Select (attr => attr.AttributeType.ToString ()); } - void VerifyFixedBufferFields (TypeDefinition src, TypeDefinition linked) + private void VerifyFixedBufferFields (TypeDefinition src, TypeDefinition linked) { var fields = src.Fields.Where (f => f.CustomAttributes.Any (attr => attr.AttributeType.Name == nameof (KeptFixedBufferAttribute))); @@ -846,7 +845,7 @@ void VerifyFixedBufferFields (TypeDefinition src, TypeDefinition linked) } } - void VerifyDelegateBackingFields (TypeDefinition src, TypeDefinition linked) + private void VerifyDelegateBackingFields (TypeDefinition src, TypeDefinition linked) { var expectedFieldNames = GetCustomAttributeCtorValues (src, nameof (KeptDelegateCacheFieldAttribute)) .Select (unique => $"<>f__mg$cache{unique}") @@ -866,7 +865,7 @@ void VerifyDelegateBackingFields (TypeDefinition src, TypeDefinition linked) } } - void VerifyGenericParameters (IGenericParameterProvider src, IGenericParameterProvider linked) + private void VerifyGenericParameters (IGenericParameterProvider src, IGenericParameterProvider linked) { Assert.Equal (src.HasGenericParameters, linked.HasGenericParameters); if (src.HasGenericParameters) { @@ -888,7 +887,7 @@ void VerifyGenericParameters (IGenericParameterProvider src, IGenericParameterPr } } - void VerifyParameters (IMethodSignature src, IMethodSignature linked) + private void VerifyParameters (IMethodSignature src, IMethodSignature linked) { Assert.Equal (src.HasParameters, linked.HasParameters); if (src.HasParameters) { diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/BaseMetadataProvider.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/BaseMetadataProvider.cs index b136da80846b4..2be52e19df6f0 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/BaseMetadataProvider.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/BaseMetadataProvider.cs @@ -85,7 +85,7 @@ protected virtual NPath SourceFileForAttributeArgumentValue (object value) return MakeSourceTreeFilePathAbsolute (value.ToString ()!); } - static TypeReference ParentMostType (TypeReference type) + private static TypeReference ParentMostType (TypeReference type) { if (!type.IsNested) return type; diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILCompilerDriver.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILCompilerDriver.cs index af5f9983e8a12..94389b716e22f 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILCompilerDriver.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILCompilerDriver.cs @@ -85,7 +85,7 @@ public void Trim (ILCompilerOptions options, ILogWriter logWriter) .UseParallelism (System.Diagnostics.Debugger.IsAttached ? 1 : -1) .ToILScanner (); - ILScanResults results = scanner.Scan (); + _ = scanner.Scan (); } public static void ComputeDefaultOptions (out TargetOS os, out TargetArchitecture arch) diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILCompilerOptionsBuilder.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILCompilerOptionsBuilder.cs index 98f0ee4351ef1..a370eff817d26 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILCompilerOptionsBuilder.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILCompilerOptionsBuilder.cs @@ -221,7 +221,7 @@ public virtual void ProcessOptions (TestCaseLinkerOptions options) AddAdditionalArgument (additionalArgument.Key, additionalArgument.Value); } - static void AppendExpandedPaths (Dictionary dictionary, string pattern) + private static void AppendExpandedPaths (Dictionary dictionary, string pattern) { bool empty = true; diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/IgnoreTestException.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/IgnoreTestException.cs index 767bc07454fcb..838edb1cdd4ba 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/IgnoreTestException.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/IgnoreTestException.cs @@ -5,7 +5,7 @@ namespace Mono.Linker.Tests.TestCasesRunner { - internal class IgnoreTestException : Exception + internal sealed class IgnoreTestException : Exception { public IgnoreTestException (string message) : base (message) { } } diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs index bb3665b65afe1..e09966f22d45c 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs @@ -22,9 +22,9 @@ namespace Mono.Linker.Tests.TestCasesRunner { public class ResultChecker { - readonly BaseAssemblyResolver _originalsResolver; - readonly ReaderParameters _originalReaderParameters; - readonly ReaderParameters _linkedReaderParameters; + private readonly BaseAssemblyResolver _originalsResolver; + private readonly ReaderParameters _originalReaderParameters; + private readonly ReaderParameters _linkedReaderParameters; public ResultChecker () : this (new TestCaseAssemblyResolver (), @@ -57,7 +57,7 @@ public virtual void Check (ILCompilerTestCaseResult trimmedResult) } } - void InitializeResolvers (ILCompilerTestCaseResult linkedResult) + private void InitializeResolvers (ILCompilerTestCaseResult linkedResult) { _originalsResolver.AddSearchDirectory (linkedResult.ExpectationsAssemblyPath.Parent.ToString ()); } @@ -76,13 +76,13 @@ protected virtual void AdditionalChecking (ILCompilerTestCaseResult linkResult, VerifyLoggedMessages (original, linkResult.LogWriter, checkRemainingErrors); } - static bool IsProducedByNativeAOT (CustomAttribute attr) + private static bool IsProducedByNativeAOT (CustomAttribute attr) { var producedBy = attr.GetPropertyValue ("ProducedBy"); return producedBy is null ? true : ((ProducedBy) producedBy).HasFlag (ProducedBy.NativeAot); } - static IEnumerable GetAttributeProviders (AssemblyDefinition assembly) + private static IEnumerable GetAttributeProviders (AssemblyDefinition assembly) { foreach (var testType in assembly.AllDefinedTypes ()) { foreach (var provider in testType.AllMembers ()) @@ -97,7 +97,7 @@ static IEnumerable GetAttributeProviders (AssemblyDefi yield return assembly; } - void VerifyLoggedMessages (AssemblyDefinition original, TestLogWriter logger, bool checkRemainingErrors) + private void VerifyLoggedMessages (AssemblyDefinition original, TestLogWriter logger, bool checkRemainingErrors) { List loggedMessages = logger.GetLoggedMessages (); List<(IMemberDefinition, CustomAttribute)> expectedNoWarningsAttributes = new List<(IMemberDefinition, CustomAttribute)> (); @@ -304,7 +304,7 @@ void VerifyLoggedMessages (AssemblyDefinition original, TestLogWriter logger, bo Assert.False (remainingErrors.Any (), $"Found unexpected errors:{Environment.NewLine}{string.Join (Environment.NewLine, remainingErrors)}"); } - bool LogMessageHasSameOriginMember (MessageContainer mc, ICustomAttributeProvider expectedOriginProvider) + static bool LogMessageHasSameOriginMember (MessageContainer mc, ICustomAttributeProvider expectedOriginProvider) { var origin = mc.Origin; Debug.Assert (origin != null); @@ -391,7 +391,7 @@ static string ConvertSignatureToIlcFormat (string value) if (part.EndsWith ('>')) { int i = part.LastIndexOf ('<'); if (i >= 0) { - sb.Append (part.Substring (0, i)); + sb.Append (part.AsSpan (0, i)); sb.Append ('`'); sb.Append (part.Substring (i + 1).Where (c => c == ',').Count () + 1); continue; @@ -405,7 +405,7 @@ static string ConvertSignatureToIlcFormat (string value) } } - static bool HasAttribute (ICustomAttributeProvider caProvider, string attributeName) + private static bool HasAttribute (ICustomAttributeProvider caProvider, string attributeName) { if (caProvider is AssemblyDefinition assembly && assembly.EntryPoint != null) return assembly.EntryPoint.DeclaringType.CustomAttributes diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseAssemblyResolver.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseAssemblyResolver.cs index dec3270905e44..d3d4601c584fd 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseAssemblyResolver.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseAssemblyResolver.cs @@ -9,7 +9,7 @@ namespace Mono.Linker.Tests.TestCasesRunner { public class TestCaseAssemblyResolver : DefaultAssemblyResolver { - readonly HashSet itemsToDispose; + private readonly HashSet itemsToDispose; public TestCaseAssemblyResolver () { diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseCompilationMetadataProvider.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseCompilationMetadataProvider.cs index 1aa354f58176b..633e191f247c0 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseCompilationMetadataProvider.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseCompilationMetadataProvider.cs @@ -58,7 +58,7 @@ public virtual bool IsIgnored ([NotNullWhen(true)] out string? reason) return false; } - bool IsRequirementMissing (TestRunCharacteristics requirement, TestRunCharacteristics testCaseRequirements) + private bool IsRequirementMissing (TestRunCharacteristics requirement, TestRunCharacteristics testCaseRequirements) { return testCaseRequirements.HasFlag (requirement) && !Characteristics.HasFlag (requirement); } @@ -90,7 +90,7 @@ public virtual string GetAssemblyName () public virtual string GetCSharpCompilerToUse () { - return GetOptionAttributeValue (nameof (SetupCSharpCompilerToUseAttribute), string.Empty)!.ToLower (); + return GetOptionAttributeValue (nameof (SetupCSharpCompilerToUseAttribute), string.Empty)!.ToLowerInvariant (); } public virtual IEnumerable GetSetupCompilerArguments () @@ -107,7 +107,7 @@ public virtual IEnumerable AdditionalFilesToSandbox () .Select (GetSourceAndRelativeDestinationValue); } - static string GetReferenceDir () + private static string GetReferenceDir () { string runtimeDir = Path.GetDirectoryName (typeof (object).Assembly.Location)!; string ncaVersion = Path.GetFileName (runtimeDir); diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseCompiler.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseCompiler.cs index 442b176c38fc6..8067d2969a4d2 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseCompiler.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseCompiler.cs @@ -39,7 +39,7 @@ public TestCaseCompiler (TestCaseSandbox sandbox, TestCaseCompilationMetadataPro public NPath CompileTestIn (NPath outputDirectory, string outputName, IEnumerable sourceFiles, string[] commonReferences, string[] mainAssemblyReferences, IEnumerable? defines, NPath[] resources, string[] additionalArguments) { var originalCommonReferences = commonReferences.Select (r => r.ToNPath ()).ToArray (); - var originalDefines = defines?.ToArray () ?? new string[0]; + var originalDefines = defines?.ToArray () ?? Array.Empty (); Prepare (outputDirectory); @@ -92,8 +92,8 @@ protected virtual CompilerOptions CreateOptionsForTestCase (NPath outputPath, NP protected virtual CompilerOptions CreateOptionsForSupportingAssembly (SetupCompileInfo setupCompileInfo, NPath outputDirectory, NPath[] sourceFiles, NPath[] references, string[] defines, NPath[] resources) { - var allDefines = defines.Concat (setupCompileInfo.Defines ?? new string[0]).ToArray (); - var allReferences = references.Concat (setupCompileInfo.References?.Select (p => MakeSupportingAssemblyReferencePathAbsolute (outputDirectory, p)) ?? new NPath[0]).ToArray (); + var allDefines = defines.Concat (setupCompileInfo.Defines ?? Array.Empty ()).ToArray (); + var allReferences = references.Concat (setupCompileInfo.References?.Select (p => MakeSupportingAssemblyReferencePathAbsolute (outputDirectory, p)) ?? Array.Empty ()).ToArray (); string[]? additionalArguments = string.IsNullOrEmpty (setupCompileInfo.AdditionalArguments) ? null : new[] { setupCompileInfo.AdditionalArguments }; return new CompilerOptions { OutputPath = outputDirectory.Combine (setupCompileInfo.OutputName), @@ -102,7 +102,7 @@ protected virtual CompilerOptions CreateOptionsForSupportingAssembly (SetupCompi Defines = allDefines, Resources = resources, AdditionalArguments = additionalArguments, - CompilerToUse = setupCompileInfo.CompilerToUse?.ToLower () + CompilerToUse = setupCompileInfo.CompilerToUse?.ToLowerInvariant () }; } @@ -367,7 +367,7 @@ protected NPath CompileCSharpAssemblyWithExternalCompiler (string executable, Co return options.OutputPath; } - static string LocateMcsExecutable () + private static string LocateMcsExecutable () { if (Environment.OSVersion.Platform == PlatformID.Win32NT) throw new IgnoreTestException ("We don't have a universal way of locating mcs on Windows"); diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadataProvider.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadataProvider.cs index dc662e4dcf584..d24956508ddf8 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadataProvider.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadataProvider.cs @@ -8,6 +8,7 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata; using Mono.Linker.Tests.Extensions; using Mono.Linker.Tests.TestCases; +using System; namespace Mono.Linker.Tests.TestCasesRunner { @@ -70,7 +71,7 @@ public virtual TestCaseLinkerOptions GetLinkerOptions (NPath inputPath) if (pos != -1) { string custom_assembly_path = values[0].Substring (pos + 1); if (!Path.IsPathRooted (custom_assembly_path)) - values[0] = values[0].Substring (0, pos + 1) + Path.Combine (inputPath, custom_assembly_path); + values[0] = string.Concat (values[0].AsSpan (0, pos + 1), Path.Combine (inputPath, custom_assembly_path)); } break; case "-a": diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseSandbox.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseSandbox.cs index c7041020c4481..5a6bd2a2d873c 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseSandbox.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseSandbox.cs @@ -14,10 +14,9 @@ public class TestCaseSandbox { protected readonly TestCase _testCase; protected readonly NPath _directory; + private const string _linkerAssemblyPath = "";//typeof (Trimmer).Assembly.Location; - static readonly string _linkerAssemblyPath = "";//typeof (Trimmer).Assembly.Location; - - static NPath GetArtifactsTestPath () + private static NPath GetArtifactsTestPath () { // Converts paths like /root-folder/runtime/artifacts/bin/Mono.Linker.Tests/x64/Debug/Mono.Linker.Tests.dll // to /root-folder/runtime/artifacts/bin/ILLink.testcases/ From da20ae6bb00767bde3ddff4d30251a60aba60f95 Mon Sep 17 00:00:00 2001 From: Tlakollo Date: Tue, 30 Aug 2022 13:59:01 -0700 Subject: [PATCH 06/11] Fix issue with Exceptions --- src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs | 2 +- .../tools/Common/TypeSystem/Common/TypeSystemHelpers.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs b/src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs index 8eefeb20bb080..c794377bf1971 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs @@ -26,7 +26,7 @@ public LayoutInt(int input) { if (input < 0) { - throw default(ArgumentException); + throw new ArgumentException(); } else { diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs index b139b1b1e6b58..4dd16d7f3c3bf 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs @@ -363,7 +363,9 @@ public static bool ContainsSignatureVariables(this TypeDesc thisType, bool treat // It is generally a bug to have instantiations over generic parameters // in the system. Typical instantiations are represented as instantiations // over own formals - so these should be signature variables instead. - throw default(ArgumentException); +#pragma warning disable CA2208 // Instantiate argument exceptions correctly + throw new ArgumentException(); +#pragma warning restore CA2208 // Instantiate argument exceptions correctly default: Debug.Assert(thisType is DefType); From 6bbfc18bb58572f693b0ed504b95d9df83b54ed4 Mon Sep 17 00:00:00 2001 From: Tlakollo Date: Tue, 30 Aug 2022 14:04:29 -0700 Subject: [PATCH 07/11] Forgot to save one file --- src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs b/src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs index c794377bf1971..7b0688cbec4f5 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs @@ -26,7 +26,9 @@ public LayoutInt(int input) { if (input < 0) { +#pragma warning disable CA2208 // Instantiate argument exceptions correctly throw new ArgumentException(); +#pragma warning restore CA2208 // Instantiate argument exceptions correctly } else { From f265423cae58e08a92178b908375e2fd2f84e1ea Mon Sep 17 00:00:00 2001 From: Tlakollo Date: Tue, 30 Aug 2022 14:53:53 -0700 Subject: [PATCH 08/11] Some refactor to not have pragmas --- src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs | 4 +--- .../tools/Common/TypeSystem/Common/TypeSystemHelpers.cs | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs b/src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs index 7b0688cbec4f5..a2067d042252c 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/LayoutInt.cs @@ -26,9 +26,7 @@ public LayoutInt(int input) { if (input < 0) { -#pragma warning disable CA2208 // Instantiate argument exceptions correctly - throw new ArgumentException(); -#pragma warning restore CA2208 // Instantiate argument exceptions correctly + throw new ArgumentOutOfRangeException(nameof(input)); } else { diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs index 4dd16d7f3c3bf..749136b698b20 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs @@ -363,9 +363,7 @@ public static bool ContainsSignatureVariables(this TypeDesc thisType, bool treat // It is generally a bug to have instantiations over generic parameters // in the system. Typical instantiations are represented as instantiations // over own formals - so these should be signature variables instead. -#pragma warning disable CA2208 // Instantiate argument exceptions correctly - throw new ArgumentException(); -#pragma warning restore CA2208 // Instantiate argument exceptions correctly + throw new InvalidOperationException(); default: Debug.Assert(thisType is DefType); From c80119eec2a7442a557147c968f9826ff88b9d87 Mon Sep 17 00:00:00 2001 From: Tlakollo Date: Tue, 30 Aug 2022 16:19:53 -0700 Subject: [PATCH 09/11] Modify LayoutIntTests to expect ArgumentOutOfRangeException instead of ArgumentException --- .../UniversalGenericFieldLayoutTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/UniversalGenericFieldLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/UniversalGenericFieldLayoutTests.cs index 338f7d8d75b90..8b430b4d72c65 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/UniversalGenericFieldLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/UniversalGenericFieldLayoutTests.cs @@ -44,8 +44,8 @@ public UniversalGenericFieldLayoutTests() [Fact] public void LayoutIntTests() { - Assert.Throws(() => { return new LayoutInt(int.MinValue); }); - Assert.Throws(() => { return new LayoutInt(-1); }); + Assert.Throws(() => { return new LayoutInt(int.MinValue); }); + Assert.Throws(() => { return new LayoutInt(-1); }); Assert.Equal(LayoutInt.Zero, new LayoutInt(0)); Assert.Equal(LayoutInt.One, new LayoutInt(1)); From 99e0547fd416855912fd486f73fa8bc84923611b Mon Sep 17 00:00:00 2001 From: Tlakollo Date: Wed, 31 Aug 2022 15:02:29 -0700 Subject: [PATCH 10/11] PR feedback --- .../Common/Compiler/NativeAotNameMangler.cs | 10 +++------- .../Generator/MdBinaryWriterGen.cs | 4 ---- .../NativeFormat/Generator/ReaderGen.cs | 5 +---- .../NativeFormat/Generator/WriterGen.cs | 15 +++++--------- .../NativeFormat/NativeFormatWriter.cs | 20 ------------------- .../ThunkGenerator/InstructionSetGenerator.cs | 10 ++++------ .../CustomAttributeTypeNameParser.cs | 9 ++++++--- .../Utilities/LockFreeReaderHashtable.cs | 4 +--- .../Ecma/EcmaSignatureTranslator.cs | 4 +--- 9 files changed, 21 insertions(+), 60 deletions(-) diff --git a/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs b/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs index 1c7c24694d27f..bcb1aeeed2ae2 100644 --- a/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs +++ b/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs @@ -15,8 +15,6 @@ namespace ILCompiler { public class NativeAotNameMangler : NameMangler { - private SHA256 _sha256; - #if !READYTORUN private readonly bool _mangleForCplusPlus; @@ -50,13 +48,13 @@ public override string SanitizeName(string s, bool typeName = false) { char c = s[i]; - if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) + if (char.IsAsciiLetter(c)) { sb?.Append(c); continue; } - if ((c >= '0') && (c <= '9')) + if (char.IsAsciiDigit(c)) { // C identifiers cannot start with a digit. Prepend underscores. if (i == 0) @@ -121,9 +119,7 @@ private string SanitizeNameWithHash(string literal) // This hash function provides an exceedingly high likelihood that no two strings will be given equal symbol names // This is not considered used for security purpose; however collisions would be highly unfortunate as they will cause compilation // failure. - _sha256 ??= SHA256.Create(); - - hash = _sha256.ComputeHash(GetBytesFromString(literal)); + hash = SHA256.HashData(GetBytesFromString(literal)); } mangledName += "_" + BitConverter.ToString(hash).Replace("-", ""); diff --git a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/MdBinaryWriterGen.cs b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/MdBinaryWriterGen.cs index 19e870feb3918..2069fd6c78a0c 100644 --- a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/MdBinaryWriterGen.cs +++ b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/MdBinaryWriterGen.cs @@ -19,13 +19,9 @@ public void EmitSource() WriteLine("#pragma warning disable 649"); WriteLine(); - WriteLine("using System;"); - WriteLine("using System.IO;"); WriteLine("using System.Collections.Generic;"); WriteLine("using System.Reflection;"); - WriteLine("using Internal.LowLevelLinq;"); WriteLine("using Internal.NativeFormat;"); - WriteLine("using Debug = System.Diagnostics.Debug;"); WriteLine(); OpenScope("namespace Internal.Metadata.NativeFormat.Writer"); diff --git a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/ReaderGen.cs b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/ReaderGen.cs index 212426070491a..d8d13be9591ef 100644 --- a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/ReaderGen.cs +++ b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/ReaderGen.cs @@ -25,10 +25,7 @@ public void EmitSource() WriteLine("#pragma warning disable IDE0059"); WriteLine(); - WriteLine("using System;"); WriteLine("using System.Reflection;"); - WriteLine("using System.Collections.Generic;"); - WriteLine("using System.Runtime.CompilerServices;"); WriteLine("using Internal.NativeFormat;"); WriteLine(); @@ -266,7 +263,7 @@ private void EmitMetadataReader() if (record.Name == "ConstantStringValue") { WriteLine("if (IsNull(handle))"); - WriteLine(" return new ConstantStringValue();"); + WriteLine(" return default(ConstantStringValue);"); } WriteLine($"{record.Name} record;"); WriteLine("record._reader = this;"); diff --git a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/WriterGen.cs b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/WriterGen.cs index 6b03f4d8c7869..14156a9bc003e 100644 --- a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/WriterGen.cs +++ b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/WriterGen.cs @@ -13,15 +13,10 @@ public void EmitSource() WriteLine("#pragma warning disable 649"); WriteLine(); - WriteLine("using System;"); - WriteLine("using System.IO;"); WriteLine("using System.Collections.Generic;"); WriteLine("using System.Reflection;"); WriteLine("using System.Threading;"); - WriteLine("using Internal.LowLevelLinq;"); - WriteLine("using Internal.Metadata.NativeFormat.Writer;"); WriteLine("using Internal.NativeFormat;"); - WriteLine("using HandleType = Internal.Metadata.NativeFormat.HandleType;"); WriteLine("using Debug = System.Diagnostics.Debug;"); WriteLine(); @@ -64,8 +59,8 @@ private void EmitRecord(RecordDef record) } CloseScope("Visit"); - OpenScope("public override sealed bool Equals(Object obj)"); - WriteLine("if (Object.ReferenceEquals(this, obj)) return true;"); + OpenScope("public sealed override bool Equals(object obj)"); + WriteLine("if (ReferenceEquals(this, obj)) return true;"); WriteLine($"var other = obj as {record.Name};"); WriteLine("if (other == null) return false;"); if ((record.Flags & RecordDefFlags.ReentrantEquals) != 0) @@ -94,7 +89,7 @@ private void EmitRecord(RecordDef record) else if ((member.Flags & (MemberDefFlags.Map | MemberDefFlags.RecordRef)) != 0) { - WriteLine($"if (!Object.Equals({member.Name}, other.{member.Name})) return false;"); + WriteLine($"if (!Equals({member.Name}, other.{member.Name})) return false;"); } else if ((member.Flags & MemberDefFlags.CustomCompare) != 0) @@ -113,7 +108,7 @@ private void EmitRecord(RecordDef record) WriteLine("finally"); WriteLine("{"); WriteLine(" var popped = _equalsReentrancyGuard.Value.Pop();"); - WriteLine(" Debug.Assert(Object.ReferenceEquals(other, popped));"); + WriteLine(" Debug.Assert(ReferenceEquals(other, popped));"); WriteLine("}"); } WriteLine("return true;"); @@ -121,7 +116,7 @@ private void EmitRecord(RecordDef record) if ((record.Flags & RecordDefFlags.ReentrantEquals) != 0) WriteLine("private ThreadLocal _equalsReentrancyGuard;"); - OpenScope("public override sealed int GetHashCode()"); + OpenScope("public sealed override int GetHashCode()"); WriteLine("if (_hash != 0)"); WriteLine(" return _hash;"); WriteLine("EnterGetHashCode();"); diff --git a/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatWriter.cs b/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatWriter.cs index 70b45a8d15ab3..bd4f0e20dac96 100644 --- a/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatWriter.cs +++ b/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatWriter.cs @@ -396,16 +396,6 @@ public void Save(Stream stream) } } -#if NATIVEFORMAT_COMPRESSION - // TODO: -#else - internal struct TypeSignatureCompressor - { - internal TypeSignatureCompressor(NativeWriter pWriter) { } - internal static void Pack(Vertex vertex) { } - } -#endif - private T Unify(T vertex) where T : Vertex { Vertex existing; @@ -935,8 +925,6 @@ public ExternalTypeSignature(uint externalTypeId) internal override void Save(NativeWriter writer) { writer.WriteUnsigned((uint)TypeSignatureKind.External | (_externalTypeId << 4)); - - NativeWriter.TypeSignatureCompressor.Pack(this); } public override int GetHashCode() @@ -1301,8 +1289,6 @@ internal override void Save(NativeWriter writer) { writer.WriteUnsigned((uint)TypeSignatureKind.Modifier | ((uint)_modifier << 4)); _param.Save(writer); - - NativeWriter.TypeSignatureCompressor.Pack(this); } public override int GetHashCode() @@ -1337,8 +1323,6 @@ public VariableTypeSignature(uint index, bool method) internal override void Save(NativeWriter writer) { writer.WriteUnsigned((uint)TypeSignatureKind.Variable | (_variableId << 4)); - - NativeWriter.TypeSignatureCompressor.Pack(this); } public override int GetHashCode() @@ -1378,8 +1362,6 @@ internal override void Save(NativeWriter writer) _typeDef.Save(writer); for (int iArg = 0; iArg < _args.Length; iArg++) _args[iArg].Save(writer); - - NativeWriter.TypeSignatureCompressor.Pack(this); } public override int GetHashCode() @@ -1443,8 +1425,6 @@ internal override void Save(NativeWriter writer) writer.WriteUnsigned((uint)_lowerBounds.Length); foreach (uint b in _lowerBounds) writer.WriteUnsigned(b); - - NativeWriter.TypeSignatureCompressor.Pack(this); } public override int GetHashCode() diff --git a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.cs b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.cs index fb97127666eb1..97c4feb5cfb04 100644 --- a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.cs +++ b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.cs @@ -375,11 +375,9 @@ public void WriteManagedJitInstructionSet(TextWriter tr) // FROM /src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txt // using /src/coreclr/tools/Common/JitInterface/ThunkGenerator/gen.bat -using System; using System.Collections; using System.Collections.Generic; using System.Linq; -using System.Runtime.InteropServices; using Internal.TypeSystem; namespace Internal.JitInterface @@ -522,7 +520,7 @@ IEnumerator IEnumerable.GetEnumerator() public IEnumerator GetEnumerator() { - for (int i = 1; i < (int)InstructionSet.NONE; i ++) + for (int i = 1; i < (int)InstructionSet.NONE; i++) { InstructionSet instructionSet = (InstructionSet)i; if (HasInstructionSet(instructionSet)) @@ -581,12 +579,12 @@ public static InstructionSet ConvertToImpliedInstructionSetForVectorInstructionS public static InstructionSetFlags ExpandInstructionSetByImplicationHelper(TargetArchitecture architecture, InstructionSetFlags input) { - InstructionSetFlags oldflags = input; + InstructionSetFlags oldflags; InstructionSetFlags resultflags = input; do { oldflags = resultflags; - switch(architecture) + switch (architecture) { "); foreach (string architecture in _architectures) @@ -624,7 +622,7 @@ public void ExpandInstructionSetByReverseImplication(TargetArchitecture architec private static InstructionSetFlags ExpandInstructionSetByReverseImplicationHelper(TargetArchitecture architecture, InstructionSetFlags input) { - InstructionSetFlags oldflags = input; + InstructionSetFlags oldflags; InstructionSetFlags resultflags = input; do { diff --git a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameParser.cs b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameParser.cs index 61eca5be798c4..8089f6585d498 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameParser.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameParser.cs @@ -376,9 +376,7 @@ private static StringIterator End(this string s) return new StringIterator(s, s.Length); } -#pragma warning disable CA1066 // Implement IEquatable when overriding Object.Equals - private struct StringIterator -#pragma warning restore CA1066 // Implement IEquatable when overriding Object.Equals + private struct StringIterator : IEquatable { private string _string; private int _index; @@ -452,6 +450,11 @@ public override int GetHashCode() { throw new NotImplementedException(); } + + public bool Equals(StringIterator other) + { + throw new NotImplementedException(); + } } #endregion } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/LockFreeReaderHashtable.cs b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/LockFreeReaderHashtable.cs index 8a298ffb4a981..ad43bf9090434 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/LockFreeReaderHashtable.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/LockFreeReaderHashtable.cs @@ -593,9 +593,7 @@ public bool Contains(TKey key) public TValue GetValueIfExists(TValue value) { if (value == null) -#pragma warning disable CA2208 // Instantiate argument exceptions correctly - throw new ArgumentNullException(); -#pragma warning restore CA2208 // Instantiate argument exceptions correctly + throw new ArgumentNullException(nameof(value)); TValue[] hashTableLocal = GetCurrentHashtable(); Debug.Assert(hashTableLocal.Length > 0); diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureTranslator.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureTranslator.cs index 96045c035358a..4ef47c3fe457a 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureTranslator.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureTranslator.cs @@ -178,9 +178,7 @@ public void ParseType() case SignatureTypeCode.Array: { ParseType(); -#pragma warning disable IDE0059 // The value is never used but is informative for other people to know what is being parsed - var rank = ParseCompressedInt(); -#pragma warning restore IDE0059 // Unnecessary assignment of a value + /*var rank = */ParseCompressedInt(); var boundsCount = ParseCompressedInt(); for (int i = 0; i < boundsCount; i++) From 0860a5028dacc816000b54027f415d27041b087c Mon Sep 17 00:00:00 2001 From: Tlakollo Date: Thu, 1 Sep 2022 08:58:02 -0700 Subject: [PATCH 11/11] Use name instead of PrimitiveType name when autogenerating types --- .../Metadata/NativeFormat/Generator/SchemaDef.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/SchemaDef.cs b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/SchemaDef.cs index 0b2980033426d..dbad36a8914b6 100644 --- a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/SchemaDef.cs +++ b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/SchemaDef.cs @@ -274,7 +274,7 @@ class SchemaDef ( from primitiveType in PrimitiveTypes select new RecordDef( - name: "Constant" + primitiveType.TypeName + "Value", + name: "Constant" + primitiveType.Name + "Value", members: new MemberDef[] { new MemberDef(name: "Value", typeName: primitiveType.Name, flags: primitiveType.CustomCompare ? MemberDefFlags.CustomCompare : 0) @@ -309,9 +309,9 @@ from primitiveType in PrimitiveTypes select ( from primitiveType in PrimitiveTypes select new RecordDef( - name: "Constant" + primitiveType.TypeName + "Array", + name: "Constant" + primitiveType.Name + "Array", members: new MemberDef[] { - new MemberDef(name: "Value", typeName: primitiveType.TypeName, + new MemberDef(name: "Value", typeName: primitiveType.Name, flags: MemberDefFlags.Array | (primitiveType.CustomCompare ? MemberDefFlags.CustomCompare : 0)) } ) @@ -759,10 +759,10 @@ from primitiveType in PrimitiveTypes select public static readonly string[] TypeNamesWithCollectionTypes = RecordSchema.SelectMany(r => from member in r.Members - let memberTypeName = member.TypeName as string - where memberTypeName != null && + let memberName = member.Name as string + where memberName != null && (member.Flags & MemberDefFlags.Collection) != 0 && - !PrimitiveTypes.Any(pt => pt.TypeName == memberTypeName) - select memberTypeName + !PrimitiveTypes.Any(pt => pt.Name == memberName) + select memberName ).Concat(new[] { "ScopeDefinition" }).Distinct().ToArray(); }