CallerFilePath relative paths #5171
Replies: 3 comments 4 replies
-
|
What's the relative file path when the function being called is in a precompiled assembly and/or reference assembly? |
Beta Was this translation helpful? Give feedback.
-
If this is your main concern, a project built with Source Link enabled and If you don't want to enable Source Link (it only affects your debug symbols so there's not a lot of reason not to), you can manually specify a <ItemGroup>
<SourceRoot Include="$(MSBuildThisFileDirectory)" />
</ItemGroup>If you don't want to enable As a final alternative, if you want a custom prefix you can specify your own <PropertyGroup>
<PathMap>$(MSBuildThisFileDirectory.Replace(',', ',,').Replace('=', '=='))=/MyCoolProject/</PathMap>
</PropertyGroup>( |
Beta Was this translation helpful? Give feedback.
-
|
I want to add my voice to support constructor overload of |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The
[CallerFilePath]attribute results in absolute paths.There should be a way to configure
[CallerFilePath]so that it uses relative paths rather than absolute paths.Yes the
stringcan be manipulated after using[CallerFilePath], but there is currently no way to prevent the absolute path from being included in the compilation, meaning it will be visible via decompilation.Implementation?
I'm not sure what the best way to implement this feature would be, but here are some ideas without a lot of thought behind them:
Assembly property? [Expand]
Then
[CallerFilePath]parameters for that assembly would be relative to the parent directory of the.csprojfile.Assembly attribute? [Expand]
Then
[CallerFilePath]parameters for that assembly would be relative to the parent directory of wherever the attribute is located.CallerFilePathconstructor overload? [Expand]or... new attributes altogether:
[CallerProjectFilePath][CallerSolutionFilePath]Beta Was this translation helpful? Give feedback.
All reactions