Skip to content

Comments

Remaining feedback part1#79011

Merged
tlakollo merged 10 commits intodotnet:mainfrom
tlakollo:RemainingFeedbackPart1
Dec 8, 2022
Merged

Remaining feedback part1#79011
tlakollo merged 10 commits intodotnet:mainfrom
tlakollo:RemainingFeedbackPart1

Conversation

@tlakollo
Copy link
Contributor

Delete remaining files inside the runtime/src/tools/illink/eng folder
Import repo root Directory.Build.props|targets
Use shared new Roslyn ApiCompat infrastructure
Reuse some of the config from the repo root instead of rewriting it again in illink
Analyzer.props from illink disabled the StyleCop.Analyzers, by using the runtime root's Directory.Build.props we include both the analyzer.props from runtime which does enable StyleCop.Analyzers and also we include the CodeAnalysis.src.globalconfig which includes a warning for several IDE codes. In order to avoid having migration problems with the old linker repo this PR disables explicitly the codes using the illink editorconfig until both codebases migrate to use runtime analyzers and format.

Tlakaelel Ceja Valadez and others added 2 commits November 29, 2022 11:17
Import repo root Directory.Build.props|targets
Remove some of the duplicated package settings defined in the repo root Directory.Build.props
Use shared new Roslyn ApiCompat infrastructure
Disable some warnings using pragmas since code is safe
@tlakollo tlakollo added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Nov 30, 2022
@tlakollo tlakollo added this to the 8.0.0 milestone Nov 30, 2022
@tlakollo tlakollo self-assigned this Nov 30, 2022
@ghost ghost added the linkable-framework Issues associated with delivering a linker friendly framework label Nov 30, 2022
@ghost
Copy link

ghost commented Nov 30, 2022

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
See info in area-owners.md if you want to be subscribed.

Issue Details

Delete remaining files inside the runtime/src/tools/illink/eng folder
Import repo root Directory.Build.props|targets
Use shared new Roslyn ApiCompat infrastructure
Reuse some of the config from the repo root instead of rewriting it again in illink
Analyzer.props from illink disabled the StyleCop.Analyzers, by using the runtime root's Directory.Build.props we include both the analyzer.props from runtime which does enable StyleCop.Analyzers and also we include the CodeAnalysis.src.globalconfig which includes a warning for several IDE codes. In order to avoid having migration problems with the old linker repo this PR disables explicitly the codes using the illink editorconfig until both codebases migrate to use runtime analyzers and format.

Author: tlakollo
Assignees: tlakollo
Labels:

area-Tools-ILLink

Milestone: 8.0.0

<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<ProduceOnlyReferenceAssembly>true</ProduceOnlyReferenceAssembly>
<!-- Used by Arcade to compute OutputPath, IntermediateOutputPath, etc. early in the import chain. -->
<OutDirName>$(MSBuildProjectName)/ref</OutDirName>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not this align with other names we have in artefacts folder?

/cc @ViktorHofer

Copy link
Member

@ViktorHofer ViktorHofer Nov 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We already have infrastructure for

  • building reference assemblies (referenceAssemblies.props)
  • referencing them from the source project (resolveContract.targets)
  • validating them against the implementation (APICompat)
  • re-generating them (GenAPI)

in libraries. Let's make sure to use that instead of duplicating it here. @tlakollo I can help with the remaining stuff.

Copy link
Member

@ViktorHofer ViktorHofer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just submitted #79268 which helps this PR and allows you to remove all the msbuild code related to reference assembly projects. I would wait for that one to be merged and then update (rebase/merge) this PR.

EDIT: It's already merged so I just provided new feedback to clean this up in the linker msbuild code.

Version version = Environment.Version;
// The linker always runs on .NET Core, even when using desktop MSBuild to host ILLink.Tasks.
_illinkPath = Path.Combine (Path.GetDirectoryName (taskDirectory), "net7.0", "illink.dll");
_illinkPath = Path.Join (AppDomain.CurrentDomain.BaseDirectory, $"net{version.Major}.{version.Minor}", "illink.dll");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right. I think AppDomain.CurrentDomain.BaseDirectory is the location of the current process, not the task DLL. My understanding of this code is that the task wants to find the location of illink.dll relative to itself. I think the Assembly.Location use was probably correct here, and the suppression is probably appropriate too as we can be confident that MSBuild will never be a single-file app.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debugging using the TestErrorHandling test these are the values:

Assembly.GetExecutingAssembly ().Location
"runtime\artifacts\bin\ILLink.Tasks.Tests\Debug\net7.0\ILLink.Tasks.dll"
AppDomain.CurrentDomain.BaseDirectory
"runtime\artifacts\bin\ILLink.Tasks.Tests\Debug\net7.0\"
_illinkPath
"runtime\artifacts\bin\ILLink.Tasks.Tests\Debug\net7.0\illink.dll"

So the only part that would be incorrect is adding the "net7.0" folder because it will already be included from getting either Assembly.Location() or BaseDirectory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I talked with Sven about the BaseDirectory location when not executed in the test environment. He agrees that the process location might variate and therefore the right approach is to use the Assembly.Location() and the suppression.

@tlakollo tlakollo requested a review from agocke December 8, 2022 00:24
Copy link
Member

@agocke agocke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tlakollo tlakollo merged commit a5e788a into dotnet:main Dec 8, 2022
@tlakollo tlakollo deleted the RemainingFeedbackPart1 branch December 8, 2022 20:55
</ProjectReference>
</ItemGroup>
<!-- Import reference assembly and ApiCompat logic -->
<Import Project="$(RepositoryEngineeringDir)resolveContract.targets" Condition="'$(IsSourceProject)' == 'true'" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the property IsSourceProject defined anywhere here? It is for all src/libraries projects but I don't think that any projects under src/tools/illink set it. That makes this target to never be imported and APICompat and other tools to never run.

@ghost ghost locked as resolved and limited conversation to collaborators Jan 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Tools-ILLink .NET linker development as well as trimming analyzers linkable-framework Issues associated with delivering a linker friendly framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants