question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Infer <Link> missing attributes for files outside of project root

See original GitHub issue

Visual Studio Version: 16.4.1

Summary: Right now, if a project contains a file outside of the project file’s subtree, it is displayed as if it was in the project folder. If there are more than a few of these, one likely wants them to be in some kind of structure and right now that can only be achieved by manually adding many “Link” attributes.

Eg., in a project we have ~50 entries like this. In this case it happens the paths are <repo-root>\src\Common\Interop\... and the project is in <repo-root>\src\Microsoft.Win32.SystemEvents

    <Compile Include="$(CommonPath)\Interop\Windows\Interop.Errors.cs">
      <Link>Common\Interop\Windows\Interop.Errors.cs</Link>
    </Compile>
    <Compile Include="$(CommonPath)\Interop\Windows\User32\Interop.Constants.cs">
      <Link>Common\Interop\Windows\User32\Interop.Constants.cs</Link>
    </Compile>

etc. It makes no difference whether Link is an attribute or an element - you can see how this is a burden to write, maintain, and it adds noise to the project and changes to it. But what is being done here is so mechanical. Can we improve the heuristic so that we can use Link less?

Perhaps if Link is not present, instead of “put everything at the root” we could use a heuristic like “remove any prefix common to the project path, then represent remainder”. In this case, there is a common prefix: <repo-root>\src. Removing that and representing the rest would put the files in the solution explorer inside Common\Interop\Windows, which is what we want in this case.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
davkeancommented, Feb 19, 2020

Playing around with this, we do already support this via globs, just not individual items.

The following:

  <ItemGroup>
    <Compile Include="..\Common\**\*.cs" />
  </ItemGroup>

Results in a tree like:

image

Going deeper into the tree:

  <ItemGroup>
    <Compile Include="..\Common\VS\**\*.cs" />
  </ItemGroup>

Results in:

image

You can actually make use of this to do this individual items by globbing (I don’t want to see what this does to evaluation time!).

<Compile Include="$(CommonPath)\**\Interop.Errors.cs">

This will result in Interop\Native becoming the LinkBase.

I’ll leave this open, but this bug basically becomes “do something smarter with individual includes”.

1reaction
jkotascommented, Jan 3, 2020

Build does not need this metadata, it is just for VS.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java file outside of source root intelliJ - spring boot
To Solve: "Java file outside of source root" · Open Project Structure. · Select Modules in Project Settings in left pane. · Click...
Read more >
"The inferred type of X cannot be named without a ...
The following error occurs when trying to build a composite TypeScript project (same happens when just using declaration: true ).
Read more >
TSConfig Reference - Docs on every TSConfig option
Intro to the TSConfig Reference. A TSConfig file in a directory indicates that the directory is the root of a TypeScript or JavaScript...
Read more >
Gradle Project Properties Best Practices
Gradle project properties provide an easy way to customise builds which may need to run differently in certain situations.
Read more >
EditorConfig settings - Visual Studio (Windows)
Settings in EditorConfig files let you maintain consistent coding styles and settings in a codebase, such as indent style, tab width, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found