image-comments
image-comments copied to clipboard
Can you add support for relative paths for images?
Issue by elbruno
Sunday May 19, 2013 at 18:31 GMT
Originally opened as https://github.com/lukesdm/image-comments/issues/10
Hi something like this
/// <summary>
/// <image url=".\images\sampleCall.png" />
/// </summary>
private VideoChannel videoChannel;
Thanks! Regards
Comment by lukesdm
Saturday Jun 01, 2013 at 13:32 GMT
Thanks for your suggestion. This should be feasible to implement in a future version. P.S. I edited your comment for code formatting to get the xml tags to show (you just need to indent each line by 4 spaces).
Comment by Llaves
Tuesday Feb 25, 2014 at 05:05 GMT
Any chance this is going to happen? My build configuration is outside my control, so being able to use a path relative to the source file rather than $(ProjectDir) or an absolute path is very important to me.
Comment by Llaves
Thursday Feb 27, 2014 at 23:17 GMT
Here's a patch to VariableExpander.cs that allows the use of the variable $(CurrentDir) to point to the directory of the document. There's probably a prettier way, but I'm not a C# programmer.
private const string PROJECTDIR_PATTERN = "$(ProjectDir)";
private const string SOLUTIONDIR_PATTERN = "$(SolutionDir)";
private const string CURRENTDIR_PATTERN = "$(CurrentDir)";
....
private string evaluator(Match match)
{
string variableName = match.Value;
if (string.Compare(variableName, PROJECTDIR_PATTERN, StringComparison.InvariantCultureIgnoreCase) == 0)
{
return _projectDirectory;
}
else if (string.Compare(variableName, SOLUTIONDIR_PATTERN, StringComparison.InvariantCultureIgnoreCase) == 0)
{
return _solutionDirectory;
}
else if (string.Compare(variableName, CURRENTDIR_PATTERN, StringComparison.InvariantCultureIgnoreCase) == 0)
{
ITextDocument document;
_view.TextDataModel.DocumentBuffer.Properties.TryGetProperty(typeof(ITextDocument), out document);
return Path.GetDirectoryName(document.FilePath) + @"\";
}
else
{
// Could throw an exception here, but it's possible the path contains $(...).
// TODO: Variable name escaping
return variableName;
}
}
Nice! I actually suggested this on Connect a few years back, but the VS team didn't carry it through. In our current solution, I have a project called DevDocs, and I'll add an images folder there, so hopefully $solutiondir/devdocs/images/thing.png should work. Agree fixed paths in the file system are less useful.
Following works for relative path:
<image url="$(ItemDir)\doc\foo.png"/>
Though I would prefer the more natural:
<image url=".\doc\foo.png"/>