Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2022-11-10Use ContainingType instead of ContainingSymbol in GetReferenceKind (#3107)HEADmainJackson Schuster
2022-11-09Implements dead branch removal for switch opcode (#2905)Marek Safar
Fixes https://github.com/dotnet/linker/issues/2888
2022-11-09Sync shared code changes from NativeAOT (#3101)Vitek Karas
Syncing back updates to the shared code from NativeAOT. Mostly formatting - runtime has enabled an analyzer which requires all members to have visibility assigned explicitly. Some cleanup.
2022-11-08Add KeptByAttribute to validate an item was kept due to a specific ↵Jackson Schuster
dependency (#3096) The tests we have in the linker try to ensure that something can only be kept for a certain reason, but it can be hard to ensure it's not being kept for another reason. For example, sometimes we use typeof(TestType) to mark a type, but that also makes it relevant to variant casting, which can cause parts of TestType to be kept for unintended reasons. This PR creates the KeptByAttribute which accepts a fully qualified string in Cecil format to indicate depenency provider (the thing that is creating the dependency that marks the item with the attribute), as well as a string representing the DependencyKind to specify the "reason" there was a dependency between the two. It also can accept a System.Type, or a System.Type + name of the member to indicate the dependency provider.
2022-11-02Don't mark override of abstract base if the override's declaring type is not ↵Jackson Schuster
marked (#3098) * Don't mark an override every time the base is abstract, only if the declaring type is also marked Adds a condition to ShouldMarkOverrideForBase to exit early if the declaring type of the method is not marked.
2022-11-02Fix branch removal in compiler generated code (#3088)Vitek Karas
Changes to processing of compiler generated methods lead to a state where we don't call constant prop and branch removal in all cases before we mark instructions of the method. This can lead to overmarking This change fixes this by making sure that the branch removal executes on the method in all cases before we mark instructions of the method. The change guarantees that all accesses to Body are after the constant prop/branch removal happened on the method. This does have one possibly negative impact: the issue described in https://github.com/dotnet/linker/issues/2937 is now consistent and happens always. Added tests. Note that there's still a whole in analysis of compiler generated code around state machines, see https://github.com/dotnet/linker/issues/3087 Basically if there's a local function which is going to be removed due to branch removal and if the body of that method contains code which produces a warning due to generic parameter validation, such warning will always be generated even though it's "dead" code and even if it's suppressed via RUC or similar. In such case the analysis can't figure out to which method the local function belongs (since the call site has been removed).
2022-10-28Check for marking virtual method due to base only when state changes (#3073)Jackson Schuster
Instead of checking every virtual method to see if it should be kept due to a base method every iteration of the MarkStep pipeline, check each method only when its relevant state has changed. Co-authored-by: Sven Boemer <sbomer@gmail.com>
2022-10-26Update linker and analyzer to handle DAM on indexable property parameters ↵Jackson Schuster
(#3081) Don't assume there is only one parameter for set and none for get. Allow DAM on the index parameters of properties. Co-authored-by: vitek-karas <10670590+vitek-karas@users.noreply.github.com> Co-authored-by: Sven Boemer <sbomer@gmail.com>
2022-10-25Change analyzer versions such that the repo can be built with .NET 7 RC2 SDK ↵Vitek Karas
(#3077) Change analyzer versions such that the repo can be built with .NET 7 RC2 SDK. - Took the versions from dotnet/runtime. - Remove CheckAttributeInstantiation method since is no longer necessary - Remove global attributes since they are no longer necessary - Workaround the fact that compiler injects System.Runtime.CompilerServices.RefSafetyRulesAttribute into every assembly to describe the language version Co-authored-by: tlakollo <tlakaelel_axayakatl@outlook.com>
2022-09-21Cleanup tests for cases which use different warnings codes that the test ↵Vitek Karas
mentions (#3044) We were lacking validation for some of the warnings, and so change in behavior of the product wasn't reflected in the tests. This cleans up tests for IL2053 and IL2054 (which are not produced anymore).
2022-09-19Remove --keep-facades option (#3036)Sven Boemer
* Remove --keep-facades option
2022-09-16Better warning message for DynamicDependency problem (#3035)Vitek Karas
* Improve warning message for DynamicDependency to include the name of the type along with the name of the member we were looking for. * Fix tests
2022-09-08Fix lint command (#3027)Tlakaelel Axayakatl Ceja
Use new version of MicrosoftCodeAnalysisVersion in linker (Copy from runtime) to fix the dotnet format command Run the dotnet format command Reenable Lint check in ci pipelines
2022-09-06Sync AOT tests with linker (#3026)Tlakaelel Axayakatl Ceja
2022-09-02Allow codefixer to annotate accessor declarations as methods (#3017)Tlakaelel Axayakatl Ceja
Allow codefixer to insert a fix in accessor declarations if we target methods Fix tests that had accessors and were annotating properties/events Add tests
2022-09-01Fixes a null ref which happens when an XML comment cref contains generic ↵Vitek Karas
instantiation (#3015) * Fixes a null ref which happens when an XML comment cref contains generic instantiation In the cref some of the symbols (for example the type argument) are missing containing symbols, which leads to null refs. In any case, we should not perform any analysis on symbols inside crefs, only on real code. So this modifies the analyzer to ignore any symbol inside a cref. Adds a test to validate this. * Simplify the test
2022-08-31Verify if COM dangerous during call site check (#3009)Jeremi Kurdek
The motivation of the change is to reduce the number of unnecessary warnings around PInvokes. The change makes the RequiresReflectionMethodBodyScannerForCallSite check for COM to decide whether dataflow analysis is needed for PInvokes.
2022-08-30Annotated TestSystemTypeBase (#3008)Jeremi Kurdek
2022-08-26Don't suppress all warnings with SuppressTrimAnalysisWarnings (#3003)Sven Boemer
This replaces https://github.com/dotnet/linker/commit/82c6dc6f82aeb90cfbe509ae07cf539eecb75550 with a different approach. Now SuppressTrimAnalysisWarnings only suppresses those warnings defined to be part of the "trim analysis" category, using a separate command-line argument. An exception is 5.0 apps, where the setting continues to suppress specific warnings for compatibility.
2022-08-26Suppress warnings in 6.0 framework (#3000)Sven Boemer
This includes a sidecar XML file which will suppress new warnings in the 6.0 framework. Note that a few of the new warnings for compiler-generated code are suppressed in 7.0 with attributes on local functions. In the XML I had to suppress them with an attribute on the user method (since the signature format doesn't support compiler-generated code). Also note that this approach only includes suppressions for the core framework, not OOB assemblies. OOB assemblies or third-party nuget packages will require a slightly different approach to avoid warnings about unresolved members referenced in XML, in apps where those assemblies aren't used. There are no warnings that we need to suppress in OOB assemblies - only new warnings in already trim-incompatible code. This also includes a fix for a varargs method issue I found while running on the 6.0 framework.
2022-08-26Do not report redundant suppressions on trimmed members (#2999)Jeremi Kurdek
* Test repro + fix * fix marked filter for events and properties * formatting fix * simplified Suppression constructor * Add more tests for events and properties
2022-08-24CodeFixer enhancements (#2994)Tlakaelel Axayakatl Ceja
* Move usage of the semantic model outside of the RegisterCodeFixesAsync method for all CodeFixers since it slows lightbulb creation * Add GetBestTypeByMetadataName from dotnet/roslyn and use it instead of GetTypeByMetadataName * Use raw string literals in all codefixers testing files (this makes some tests to require spaces instead of tabs and change line numbers) * More nit fixes to make test more consistent * Rename DAMCodeFixProvider to DynamicallyAccessedMembersCodeFixProvider * Add helper class for codeFixer
2022-08-23Add generated test (#2995)Jackson Schuster
2022-08-23Add support for generic attributes (#2980)Sven Boemer
* Add generic attribute tests * Update cecil
2022-08-19IL2121 warnings point to XML files correctly (#2965)Jeremi Kurdek
Warnings indicating an unnecessary suppression produced by XML are now pointing to the xml location instead of being generated on the member the xml targets.
2022-08-18CodeFix Support for Additional DAM IDs (#2939)Isabel Serrato
* Expand Code Fix support to 23 DynamicallyAccessedMembers trim warnings * Pass information about where and what attribute needs to be added from the analyzer to the diagnostic so the Code Fix can target a greater number of warnings * Include additional tests to ensure that Code Fix is provided as expected, and check edge cases * Multiple annotations and merging of existing annotations is unsupported
2022-08-18Don't track current field of state machines (#2979)Sven Boemer
There was a performance problem where we were tracking all possible returned values throughout the method, since we were treating them the same as hoisted locals. I'm sure it's still possible to come up with testcases that show bad performance (for example assigning many arrays to a hoisted local in the same iterator), but this should at least fix the immediate issue encountered in runtime.
2022-08-17Add test for dotnet/runtime#73048 (#2977)Michal Strehovský
Running dataflow analysis on the added test takes about 20 seconds. Double the number of `yield returns` and it will take several minutes. In the runtime repo we're running into this on https://github.com/dotnet/runtime/blob/main/src/libraries/System.Runtime.Serialization.Formatters/tests/BinaryFormatterTestData.cs (method `SerializableObjects()`). That one has even more `yield returns` and I lost patience waiting for it to finish.
2022-08-15Suppress warning in instance fields if the instance constructors are ↵Tlakaelel Axayakatl Ceja
annotated with Requires (#2973)
2022-08-15Add IL Verification to tests (#2960)Jackson Schuster
Adds an ILVerifier to check that the IL produced by the linker is valid. Unsafe C# produced unverifiable code, so we skip verification when we pass that flag to the compiler. Also, there are a few warnings that are produced by valid C# with new features like static abstract interface methods and ref fields and ref returns. In the future, it may be nice to add better error messages with the type, method name, and IL offset that produced the error, and perhaps an [ExpectedILVerifyError] attribute instead of filtering all of a type of error, but those are non-trivial to implement and don't occur in many tests (<10), so I haven't done that yet.
2022-08-15Add MakeGenericMethod tests for static interface methods (#2962)Jackson Schuster
2022-08-12Dataflow support for ref fields (#2947)Jackson Schuster
Adds support and basic tests for ref fields. The tests ensure that a value written to an ref field is properly annotated, or an address written to a ref field has a properly annotated value, but there are some holes that can be created by assigning the address of a local or over-annotated value to an annotated ref field.
2022-08-12Fix il corruption (#2966)Sven Boemer
This prevents invalid IL in situations where removing the last instruction of a method would result in the last instruction being a conditional branch. There needs to be some IL in the not-taken branch for the IL to be valid, so this fixes the issue by injecting "ldnull; throw" at the end. Co-authored-by: vitek-karas <10670590+vitek-karas@users.noreply.github.com> Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
2022-08-11Process static interface methods as virtual methods (#2926)Jackson Schuster
Static methods implementing static interface methods are not marked as virtual and were not checked for matching RUC and DAM annotations. This change adds all base methods to the _virtual_methods list to be checked for matching DAM and RUC annotations. This may cause extra/unnecessary warnings for mismatched annotations even a method is removed by the linker.
2022-08-09Test that basic ref field operations don't crash linker (#2952)Jackson Schuster
Adds test to use ref fields in various ways to confirm that they don't cause the linker to crash.
2022-08-09Fixed IL2121 single warn issue (#2953)Jeremi Kurdek
2022-08-08Aot to linker sync (#2944)Vitek Karas
Sync tweaks necessary for the linker/AOT integration
2022-08-04Improve tests and docs (#2941)Mike Voorhees
* Add a test for the `<namespace>` element. There were no tests. * Expand `CanPreserveTypesUsingRegex` to help highlight how it behaves differently from `<namespace>` * Add more examples to the docs
2022-08-04Adds a test with two annotated out params for the same method. (#2875)Vitek Karas
Test for https://github.com/dotnet/linker/issues/2874.
2022-08-04New constraint on a generic argument involved in MakeGenericType/Method ↵Vitek Karas
should warn (#2942) For correctness linker must be able to validate that generic parameters with new constraint will have their default .ctor preserved. If that can't be guaranteed, it needs to warn. Added tests for cases around this. Nullable<> is the only exception to this rule, so changed the code to completely skip any validation for it.
2022-08-03Separate interface method trimming logic and update for static interface ↵Jackson Schuster
methods (#2868) Fixes #2865 Also addresses marking of all static interface methods encompassing the changes from #2859, and updates the way that all interface methods are marked. Whether or not we mark an interface method due to its base method is now separated from marking other virtual methods and the marking is postponed to ProcessMarkedTypesWithInterface. In ProcessMarkedTypesWithInterfaces, interface implementations are marked, and methods that implement a marked/implemented interface are marked. Tests for static interface methods have also been updated. Co-authored-by: Sven Boemer <sbomer@gmail.com>
2022-08-02Redundant suppressions support for suppressions on events and properties ↵Jeremi Kurdek
(#2925) (#2940)
2022-08-02Redundant suppressions detection (#2922)Jeremi Kurdek
Implementation of the feature described in #2891.
2022-08-01Sync test changes from AOT (#2912)Vitek Karas
2022-08-01Add another local function branch removal test (#2931)Sven Boemer
This is like the existing test, but additionally shows a visible difference in the warning behavior. When the warning is produced for generic arguments rather than dataflow, it will show up even if we don't do dataflow for the local function whose callsite was removed. When branch removal breaks the link between the local function and its user method, this can result in warning suppressions that don't take effect. We could use the desired warning behavior to decide what the fix needs to do (whether it should do compiler-generated owning method detection before vs after constant propagation for the method).
2022-08-01Make serialization discovery opt-in (#2929)Sven Boemer
Serialization discovery is an undocumented quirk that exists for back-compat in xamarin scenarios. We turned it on by default in .NET 6, but would like to remove such quirks from the default options in .NET 7. This changes the (undocumented) command-line option to be opt-in. Xamarin SDKs will be expected to pass this option by setting <_ExtraTrimmerArgs>--enable-serialization-discovery</_ExtraTrimmerArgs>.
2022-07-29Add an interesting test case for compiler generated code marking (#2928)Vitek Karas
See the test for description of what it does. It's basically the linker repro for the case hit in https://github.com/dotnet/runtime/issues/73027#issuecomment-1199199943
2022-07-29Added support for suppressions on properties (#2925)Jeremi Kurdek
Suppressions can be now placed on properties and events.
2022-07-28[main] Update dependencies from dotnet/arcade (#2884)dotnet-maestro[bot]
[main] Update dependencies from dotnet/arcade - Bump to 7.0 preview6 sdk Fixes the dotnet-format issue. - Use TryGetValue instead of ContainsKey for Dictionary Fixes "error CA1854: Prefer a 'TryGetValue' call over a Dictionary indexer access guarded by a 'ContainsKey' check to avoid double lookup" - Seal classes to fix CA1852 - Add 7.0 P6 runtime - Upgrade SDK to nightly Preview 7 to get a fix for dotnet test bug
2022-07-27Add more tests for parameter dataflow (#2918)Sven Boemer
Add tests for some edge cases due to the analyzer not treating captured parameters as hoisted variables like the linker does. Currently the analyzer doesn't detect hoisted parameters, and it will treat them like normal parameters - warning if a parameter is assigned a value with an annotation that doesn't match the parameter annotation. The linker will treat captured parameters the same as other captured variables, tracking all values that get assigned. So there is a subtle difference in the warning behavior: - Linker won't warn on assignment to annotated captured parameter, but analyzer will. - Linker will produce dataflow warnings for all values assigned to a captured parameter, but analyzer will not.