Age | Commit message (Collapse) | Author |
|
[main] Update dependencies from dotnet/arcade
- Update the linker repo to .NET 7
Some small refactoring of the build files to avoid having to update multiple places with the new TFM.
Note that not all can be updated as they are used verbatim in the NuGet package, so can't rely on repo-only properties.
Also currently I left the source code to repeat these. Eventually we might investigate generating `.cs` files in the msbuild to "inject" the TFM and other constants from the MSBuild to the compiled code.
For the Roslyn tests, I hardcoded a new 7.0.0-preview.2 ref package reference, but this feels really weird - note that so far we've been testing against 6.0.0-preview.5 version. Ideally there would be some way to deduce the ref package version from the currently used SDK, and use that in the tests.
The formatting changes are induced by running `lint`. I assume this is because of the SDK version change as well, but I don't know for sure.
- Merge branch 'darc-main-3a65fa7f-262c-4578-97fd-670249162fc8' of https://github.com/dotnet/linker into darc-main-3a65fa7f-262c-4578-97fd-670249162fc8
- Merge remote-tracking branch 'mono/main' into darc-main-3a65fa7f-262c-4578-97fd-670249162fc8
- Update to preview 3 SDK
- Update to .NET 7 Preview 4 which should have the necessary changes.
- Formatting
|
|
of the file (#2469)
Some of the files that hold a license from a third party now have the two licenses as header files
Linker now uses the sdk format of license header instead of the runtime one
Added having the license header as warning in the editor config
Added THIRD-PARTY-NOTICES.TXT file to the repo root
|
|
Adds xml schema for ILLink.LinkAttributes.xml, and adds relative paths to the schema in xml used in unit tests to enable linting.
|
|
When create a type reference for the target of a type forwarder, if the type forwarder is for a nested type, we have to build a whole tree of type references for all of the declaring types and not just the final nested type.
Enabled tests which were already added for this case (and fixed a bug in them)
|
|
The problematic scenario is if there's a "copy" assembly with a forwarder to a "link" assembly with a forwarder. The forwarder is for a nested class.
Test for https://github.com/dotnet/linker/issues/2359.
Also improved the test infra to print out errors from ilasm if they happen.
|
|
|
|
* Build testcases against reference assemblies
* Reproduce issue in testcase
* Add TypeReferenceMarker
* Update one more testcase
* Don't mark forwarders in TypeReferenceMarker
Leave the logic as before and mark them from MarkStep.
* PR feedback
- Use ref assemblies for ReferenceAttribute
- Avoid adding to common references unless needed by test dependencies
|
|
|
|
* Fix writing of updated copyused scopes
Fixes https://github.com/mono/linker/issues/2138
* Fix using order
|
|
argument (#2099)
|
|
|
|
* Stop rewriting scopes for copy assemblies with removed references
* Keep exported types in copy assemblies
Mark dynamically accessed forwarders
Add tests
* Transitive forwarders are linked
* Keep copyused behavior
* Tests
* Mark type if it's exported
* PR feedback
* Transitively mark forwarders when a facade is dynamically accessed and has copy action
* Transitively mark forwarders
* Fix formatting
* Update MarkExportedType
* Keep mscorlib assert
* Mark forwarders when there's a type ref to an exported type in a copy assembly
* Update DependencyKind
* Keep forwarders when member ref is resolved from a copy assembly
* Add more tests, mark forwarded CAs
* Mark forwarded interfaces
* Simplify logic for typerefs
* Clean
* Keep ProcessInternalsVisibleAttributes in process while-loop
* Fix whitespace formatting
* Remove unused param
* Feedback
* Whitespace formatting
* Remove unnecessary assembly
* Add IL2104 warning
* Remove unnecessary marking
* Update comment
* Remove ExportedTypeExtensions
* Remove formatDiagnostics and revert cecil subm change
* Remove warning
* Comment out check for removed warning
* Update more of existing calls
* Reproduce attribute issue
* Update scopes before sweeping forwarders
* Remove my enum from compilation
* Fix formatting
* Keep same behavior for scopes in copyused assemblies
Co-authored-by: Marek Safar <marek.safar@gmail.com>
Co-authored-by: Sven Boemer <sbomer@gmail.com>
|
|
This reverts commit 1d96189abb1b2cfe00dff817c63b84b25534746a.
|
|
Co-authored-by: Marek Safar <marek.safar@gmail.com>
|
|
* Support attribute opt-in
* Update docs
* Rename test attributes to match
* Don't pass native SDK assemblies to tests
on Windows
* Update LinkTask
* PR feedback
- Don't warn on duplicate attributes
- Remove comment
- Fix typos and wording
- Use static array
- Rename CheckIsTrimmable -> IsTrimmable
* PR feedback: rename options
- --trim-action -> --trim-mode
-- --default-action -> --action
* Fix ILLink.Tasks test
* PR feedback
- Add plenty of comments
- RootNonTrimmableAssemblies -> ProcessReferencesStep
- Make -reference order stable using List instead of HashSet
* PR feedback
Make GetInputAssemblyPaths private
|
|
We used to probe for assemblies in:
- the working directory
- next to any root assembly
- in directories passed on the command-line
Now we will only probe for directories passed on the command-line, which
aren't used by the SDK.
Some of the testcases have references to mscorlib (either from .il, or from
checked-in dlls), which references System.Security.Permissions. This isn't
included with netcoreapp, but the tests used to resolve it from the
working directory of Mono.Linker.Tests.dll. We pass --skip-unresolved true
to keep these testcases from throwing resolution errors with the change.
Fixes https://github.com/mono/linker/issues/1539
|
|
This fixes a bug in the linker where it would not update the scope of TypeReferences on ISecurityAttributeProviders
This would result in references to `netstandard` surviving linking in situations where netstandard was linked away and SecurityAttribute's survived. For us this would happen when facades were linked away and an assembly had the `AssemblyAction.Copy`. There may have been other scenarios where it was possible to hit this.
I did not write a test for this. It would be hard to write one. I don't think it's worth the effort.
|
|
* Remove LoadReferencesStep
Introduce TryResolve helper, and avoid some calls to GetLoadedAssembly
* Load assemblies lazily
- Run TypeMap logic on-demand
- Register every resolved assembly
so that it gets an action
- Process embedded XML files lazily
- Run body substitutions lazily
- Introduce abstraction to allow XML processing
to run before or during MarkStep
- Iterate over reference closure when needed
instead of only looking at loaded assemblies
- Track applied preserve info
so that it may be changed by new XML
- Only mark assemblies when used
- Introduce test attributes
to check instructions in other assemblies
- Add a base class for per-assembly logic
Squashed commit with updates, cleanup, PR feedback
Cleanup
Clean up copy/save mark logic
Call TryResolve where we used to look for loaded assemblies without throwing
Process XML from type forwarder assemblies
PR feedback
- Prefix "assembly" field with underscore
- Change "context" field to a property
Separate per-assembly step processing
Embedded XML is now read only when needed, with separate caches for descriptors,
substitutions, attributes, removing unreachable blocks, and remaining
per-assembly steps. The attribute cache is kept on CustomAttributeSource.
BaseAssemblyStep -> BasePerAssemblyStep
And don't implement IStep. Instead, take an assembly and context in the ctor.
Some PR feedback
- Don't change GetType use in attribute XML
- Add clarifying comments
- Avoid an extra cache for marking entire assembly
PR feedback
- remove Delete case (this command-line option will be removed)
- change EmbeddedXmlStep -> EmbeddedXmlInfo static class
PR feedback
- Don't support xml in pure facades
- Update constant prop test after rebase
- Slightly clean up RemoveUnreachableBlocksStep
* Add tests for swept references
And fix up some existing tests
* Add lazy loading testcases
- RemoveAttributeInstances from lazy XML
- Changing TypePreserve from lazy XML
- Substitutions from lazy XML
- Constant propagation in lazy assemblies
* Keep copy/save behavior for lazy assemblies
* Avoid loading all references while sweeping
* Ensure that unused assemblies have references removed
We used to remove references to any resolved assembly that was unused.
Now, an unused assembly may not have been resolved at all, so we need to
iterate over references that might resolve to an unused assembly to ensure
that they are removed.
Iterating over all references from loaded assemblies accomplishes this,
but we might miss a resolved unused assembly that was never referenced,
and never set its action to Delete. (This can happen for type forwarders,
for example.) A simple pre-pass over loaded assemblies ensures we handle
this case.
* Remove DynamicDependencyLookupStep
* Change corlib search order
To avoid loading mscorlib in most cases. Otherwise we load mscorlib and
do a bunch of unnecessary work to resolve all of its exported types.
Fixes CanEnableReducedTracing, which was getting a lot of spew from
the exported type marking for mscorlib.
* Fix behavior of mono steps
- Run RemoveSecurityStep for lazy assemblies
- Resolve mscorlib in LoadI18nAssemblies
* Turn on tracking of lazy pending members
* Move MarkExportedTypesTargetStep
* Hide substitution processing inside helper class
This class mediates access to the method actions which can be set by
substitution xml.
Also fix and enable the constant prop testcases which depend on
substitutions.
* Load all references for IDynamicInterfaceCastable
This preserves the behavior which searches all referenced assemblies
for interfaces with DynamicInterfaceCastableImplementationAttribute,
and keeps them if they implement any marked interfaces.
* PR feedback
- Clean up dead code
- Clean up use of non-generic IDictionary
- Add file headers
- Use static classes for per-assembly logic
- Link to open github issues
- Avoid "step" terminology for per-assembly logic
* Move attribute/substitution processing to cache initialization
Instead of calling EnsureProcessed at key points, the attribute XML
processing is now done as part of cache initialization when it is first
accessed.
GetCustomAttributes, GetAction, and similar will no longer trigger
processing that adds attributes to the global store. Instead, we maintain
separate global and per-assembly stores, where the precedence
(global > per-assembly) is explicit in the getters.
In the case of attributes, the precedence is not important because they
are additive, but it does matter for the method actions which can be
mutated.
As part of the change, the attribute/substitution steps have been separated
into steps (which run on command-line XML) and parsers (which are run on
cache initialization for the embedded XML). The steps are simple wrappers
that call the parsers. The parsers can either return a new object representing
the parsed information, or they can modify a passed-in object. The latter is
used for the command-line XML steps which modify the global store of attributes
or substitutions.
* Pick better names
CustomAttributeSource.GlobalXmlInfo -> GlobalAttributeInfo
LinkAttributesParser._xmlInfo -> _attributeInfo
* PR feedback
- Rename "Global" to "Primary"
- Use TryGetValue
- Use properties instead of fields
* Rename more things
- SubstitutionInfo.SetAction -> SetMethodAction
- SubstitutionInfo.SetSubstitutedInit -> SetFieldInit
- ProcessLinkerXmlStepBase -> ProcessLinkerXmlBase
* Separate shared XML logic from IStep interface
- Make ProcessLinkerXmlBase not an IStep
- Separate descriptor marking logic from IStep implementation in
ResolveFromXmlStep
- Introduce DescriptorMarker helper similar to the XML parsers
- Remove parse overload that returns XML info
- Provide context to ctor of XML processing logic
|
|
Co-authored-by: Sven Boemer <sbomer@gmail.com>
Co-authored-by: Vitek Karas <vitek.karas@microsoft.com>
|
|
|
|
|
|
Sweep step resolves type forwarders and replaces them with direct type refs. There were already special cases for generic instantiations and array, but other type specifications were missing, most notably pointer types.
Added handling of all type specifications and added some tests.
|
|
and fix breaking changes
|
|
Every test .cs file must be able to resolve a type of the same name during test execution. Otherwise it triggers a warning and if warnings ever accumulate it becomes impossible to notice when you have a test type name that doesn't match the file name
The rule of thumb to follow is, never #if out the test case type definition. Include an ignore and and exclude any code that can't compile.
* Fix `DebuggerDisplayAttributeOnTypeCopy` only existing when `NETCOREAPP` is defined. I just removed the define. I don't see why it wouldn't work on .NET Framework
* Fix `DefaultInterfaceMethodCallIntoClass` only existing when `NETCOREAPP` is defined. I most of the test is #if away when not `NETCOREAPP` app and an `[IgnoreTestCase]` is included
* Fix `GenericDefaultInterfaceMethods` only existing when `NETCOREAPP` is defined. I most of the test is #if away when not `NETCOREAPP` app and an `[IgnoreTestCase]` is included
* Fix `SimpleDefaultInterfaceMethod` only existing when `NETCOREAPP` is defined. I most of the test is #if away when not `NETCOREAPP` app and an `[IgnoreTestCase]` is included
* Fix `UnusedDefaultInterfaceImplementation` only existing when `NETCOREAPP` is defined. I most of the test is #if away when not `NETCOREAPP` app and an `[IgnoreTestCase]` is included
* Fix `AttributeScopeUpdated`. The type name did not match the file name.
|
|
Fixes #1304
|
|
- Add SetupLinkerDescriptorFile option to differentiate Descriptor xml
from substitution and attribute xml
- Add missing SetupLinkerDescriptorFile test attributes
- Delete no longer valuable test
Co-authored-by: Tlakollo <tlcejava@microsoft.com>
|
|
* Apply consistent formatting based on .editorconfig
```
dotnet format -f <path>
```
* Add lint step to the CI
* Use local tool
* Suppress publish logs warning
* Fix more style errors
* Fixes bad merge
* Write something to log dir
* Move lint job to global scope
So it doesn't get the arcade publish logs/test steps injected.
* Split sources and tests reporting
* Include also src folder in the run
* Exclude cecil sources
* Remove duplicate line
* Trigger notification
* Format more code
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
|
|
regenerating the assembly.
Fixes #1108
|
|
Fix two type forwarding tests. On .NET FW the built in compiler will drop the reference to the forwarder assembly when compiling the test assembly. Use roslyn to give consistent behavior across platforms
|
|
only in case any of their dependencies was removed
Follow up fix for #737
|
|
to actually test what it says it does
|
|
|
|
Adds traversing of all CA values. Fixes #737
|
|
- Add more type forwarding tests
- Makes this step faster
|
|
* Fix MissingTargetReference on .NET Core
The test was failing because TypeForwarderMissingReference.il depends
on mscorlib without a version, and roslyn was looking for Object in
mscorlib, Version=0.0.0.0 as a result. This doesn't happen when using
csc from the command line because csc uses a different assembly
identity comparer by default: DesktopAssemblyIdentityComparer (even on
.NET Core).
* Also enable CanCompileILAssembly
* Also enable UnusedAttributeOnReturnTypeIsRemoved
|
|
This enables the unit tests to run on .NET Core. CodeDom compilation doesn't exist on core, so I've added the ability to compile in-process with Roslyn APIs. This still uses NUnit, using a recent version of NUnit package references with "dotnet test". This doesn't change how tests run on mono.
Finding the right reference assemblies for compilation is a bit different on .NET Core. As described in https://github.com/dotnet/roslyn/wiki/Runtime-code-generation-using-Roslyn-compilations-in-.NET-Core-App, they can either be found using packages (what the SDK does), or we can just compile against the implementation assemblies. In this change, I'm compiling against implementation assemblies, since that's fairly similar to what the tests do on mono, where they find them in the GAC.
For mono, the common references only included mscorlib. For .NET Core, I'm getting the common references from the "Trusted Platform Assemblies" (TPA) of the test process. As a result, package references of the test project become references during testcase compilation. Explicit references specified via `ReferenceAttribute` in a testcase are looked for alongside the host process's implementations as well (since we have no way to resolve a reference from just the filename since there is no GAC).
Other changes:
- Roslyn outputs the `DebuggableAttribute` by default but mcs does not, so when running on .NET Core, we don't check for the `DebuggableAttribute`.
- Check for core types in `System.Private.CoreLib` instead of `mscorlib`.
- There are some more edge cases that I'm in the process of cleaning up and will update soon.
At the moment, I'm trying to get the tests up and running, and I'm using plenty of compile-time conditions to modify the behavior on core. It would be nice not to have to do this - I haven't given it much thought, but maybe we could provide an abstraction that contains knowledge of the platform libraries, so that we don't have to have a hard dependency on `"mscorlib.dll"` and `"System.Private.CoreLib.dll"` everywhere? @mrvoorhe please let me know if you have any thoughts. Does the approach I'm taking so far seem sane to you?
@marek-safar
|
|
This organizes the source and test projects as follows:
- source projects go in `src/project/projectfile.csproj`
- test projects go in `test/project/projectfile.csproj`
The uniform layout of projects is part of the arcade onboarding (see https://github.com/mono/linker/issues/452).
|