These are chat archives for AvaloniaUI/Avalonia

29th
Nov 2016
José Manuel Nieto
@SuperJMN
Nov 29 2016 17:22
FIXED!!!
José Manuel Nieto
@SuperJMN
Nov 29 2016 17:27
it was one of the nastiest bugs I have dealt with
José Manuel Nieto
@SuperJMN
Nov 29 2016 17:41
image.png
Finally, OX2 loading the Control Catalog :)
José Manuel Nieto
@SuperJMN
Nov 29 2016 18:51
hey, one question about Uris
in the current version of Avalonia UI, Resource Uris pose a problem that I don't know how to solve
Given an absolute Uri Like "resm:Something.Some.Thing?assembly=SomeAssembly" and a relative Uri like "/Subpart/resource", it's not clear how they merge
José Manuel Nieto
@SuperJMN
Nov 29 2016 18:56
what's the base of Something.Some.Thing ?
the mapping between a path and a resource name is not bijective
José Manuel Nieto
@SuperJMN
Nov 29 2016 19:04
For example, a resource with the physical path "root/folder/MyClass.xaml" and another with "root/folder/MyClass/Xaml will translate to the same "root.folder.MyClass.xaml"
I think we should keep path separated from the name of the resource itself, in order to be able to calculate a base path from an absolute path
Currently, I'm using "resm:[Assembly]/sub1/sub2/resource"
it's a custom Uri scheme
To deal with them I had to play with the UriParser class (https://msdn.microsoft.com/en-us/library/system.uriparser(v=vs.110).aspx), that is pure shit. But I haven't found a better way to use the built-it Uri class for resources
José Manuel Nieto
@SuperJMN
Nov 29 2016 19:09
Otherwise, we might have to work with a custom Uri class
Steven Kirk
@grokys
Nov 29 2016 19:19
yeah, the resm: URI scheme isn't relative - it just looks for the resource with the specified key in the resource manifest. those keys can be anything; it just happens that by default visual studio uses the path in the project separated by .
but you can add them with any key
if we want something like WPF's, that can be relative we'll need either to create our own resource sceme or implement WPF's resources on mono
.net core probably only supports manifest resources too, i'm guessing
resm:[Assembly]/sub1/sub2/resource - so we intentionally didn't use a scheme like that as manifest resources aren't a tree
they're just key:value pairs
Steven Kirk
@grokys
Nov 29 2016 19:25
does that make sense?
José Manuel Nieto
@SuperJMN
Nov 29 2016 19:45
I don't know :) I just know that, when loading a XAML file, we need a base address from which the relative addresses can be calculated
otherwise, we would only know the address of the XAML being loaded, that isn't useful to map resources inside that XAML :(
We need addresses that, given the address of a base resource (for example, a Page, Window or UserControl...) relative addresses could be calculated easily
The format is free
What I have discovered with the current Uris is that it doesn't fit well inside a Uri
José Manuel Nieto
@SuperJMN
Nov 29 2016 19:51
maybe we don't need Uris, but we need something that given an absolute address, we can decompose it into base + relative, and to be able to generate absolute addresses given a base + relative
Steven Kirk
@grokys
Nov 29 2016 20:32
hmm, sounds like you are hving 2 problems, relative resources and "current Uris is that it doesn't fit well inside a Uri"
lets address the second issue first
why don't the current resm: URIs fit will inside a Uri?
Steven Kirk
@grokys
Nov 29 2016 20:45
what do you mean by "To deal with them I had to play with the UriParser"
José Manuel Nieto
@SuperJMN
Nov 29 2016 21:37
About the UriParser, in order to make the Uri objects work OK, I had to register an Uri parser for the resm scheme
In order to make the custom Uris work, I mean. That includes calls like new Uri(base, relative)
Steven Kirk
@grokys
Nov 29 2016 21:40
hmm, we've not had to do that previously - any idea why we've not run into that problem?
José Manuel Nieto
@SuperJMN
Nov 29 2016 21:40
With the current implementation, you could not make something like this:
var calculated = new Uri(new Uri("resm:MyResource", UriKind.Absolute), "relativepart")
Steven Kirk
@grokys
Nov 29 2016 21:42
ok, so it's because you're trying to use relative URLs
but you'd can't have relative URLs with manifest resources (resm means "manifest resources")
José Manuel Nieto
@SuperJMN
Nov 29 2016 21:43
Mostly, but also because Uris inherently support base addresses
Steven Kirk
@grokys
Nov 29 2016 21:44
because Uris inherently support base addresses
what do you mean by that?
José Manuel Nieto
@SuperJMN
Nov 29 2016 21:44
That given an absolute address, then you can infer the base
Steven Kirk
@grokys
Nov 29 2016 21:45
you can do that with many URI schemes but by no means with all of them
José Manuel Nieto
@SuperJMN
Nov 29 2016 21:45
Or, well, I think we need tob
Steven Kirk
@grokys
Nov 29 2016 21:46
the problem, as i mentioned before is that manifest resources aren't hierarchical
they're just key:value pairs
to support hierarchical resources, WPF had to invent its own resource format
so yes, it would be nice to have, but it's a lot more work
you can use this method to look at the resources in an assembly: https://msdn.microsoft.com/en-us/library/system.reflection.assembly.getmanifestresourcenames.aspx
and as you can see it's just a plain list
José Manuel Nieto
@SuperJMN
Nov 29 2016 21:58
But, how could you calculate the Uri of an Image specified in XAML as "MyImage.png" when you only have the resm address of the parent Window?
Steven Kirk
@grokys
Nov 29 2016 22:00
supposing the parent window was in MyAssembly.dll you would use resm:MyImage.png?assembly=MyAssembly
there was a short discussion on how resm: resources are formatted here: AvaloniaUI/Avalonia#282
Steven Kirk
@grokys
Nov 29 2016 22:06
i had hoped to allow relative resources but it's just not practical because when VS chooses a name for a resource it uses . as a path separator so Foo/Bar.png and Foo.Bar.png will have the same name
(btw, the discussion was had here, so it was longer than what you can see in that issue)
José Manuel Nieto
@SuperJMN
Nov 29 2016 22:45
sorry for the mistakes! I was on my mobile phone... and waiting on a waiting room in the hospital
nothing severe
OK, I will try to handle with those Uris. So, right now, the only thing we can infer from a parent Window is the Assembly part, right?
Steven Kirk
@grokys
Nov 29 2016 23:08
oh no, hope everything is ok!
but unfortunately, yes - until we can either use WPF resources on mono/core or we come up with our own way to store resources