@@ -52,7 +52,8 @@ internal partial class XamlCodeGeneration
52
52
private readonly string _projectDirectory ;
53
53
private readonly string _projectFullPath ;
54
54
private readonly bool _outputSourceComments = true ;
55
- private readonly bool _xamlResourcesTrimming ; private readonly RoslynMetadataHelper _metadataHelper ;
55
+ private readonly bool _xamlResourcesTrimming ;
56
+ private readonly RoslynMetadataHelper _metadataHelper ;
56
57
57
58
/// <summary>
58
59
/// If set, code generated from XAML will be annotated with the source method and line # in XamlFileGenerator, for easier debugging.
@@ -408,7 +409,7 @@ IEnumerable<Exception> Flatten(Exception ex)
408
409
409
410
return Location . Create (
410
411
xamlFile . Path ,
411
- xamlText . Lines . ElementAtOrDefault ( xamlParsingException . LineNumber . Value - 1 ) . Span ,
412
+ xamlText . Lines . ElementAtOrDefault ( xamlParsingException . LineNumber . Value - 1 ) . Span ,
412
413
new LinePositionSpan ( linePosition , linePosition )
413
414
) ;
414
415
}
@@ -439,7 +440,7 @@ private void BuildAmbientResources(XamlFileDefinition[] files, XamlGlobalStaticR
439
440
from module in sym . Modules
440
441
from reference in module . ReferencedAssemblies
441
442
442
- // Only consider assemblies that reference Uno.UI
443
+ // Only consider assemblies that reference Uno.UI
443
444
where reference . Name == "Uno.UI" || sym . Name == "Uno.UI"
444
445
445
446
// Don't consider Uno.UI.Fluent assemblies, as they manage their own initialization
@@ -556,7 +557,8 @@ private string[] GetResourceKeys(CancellationToken ct)
556
557
resourceKeys = _resourceFiles
557
558
. AsParallel ( )
558
559
. WithCancellation ( ct )
559
- . SelectMany ( file => {
560
+ . SelectMany ( file =>
561
+ {
560
562
this . Log ( ) . Info ( "Parse resource file : " + file ) ;
561
563
562
564
//load document
@@ -716,7 +718,7 @@ private string GenerateGlobalResources(IEnumerable<XamlFileDefinition> files, Xa
716
718
{
717
719
writer . AppendLineInvariant ( "_dictionariesRegistered = true;" ) ;
718
720
719
- if ( ! IsUnoAssembly && ! IsUnoFluentAssembly )
721
+ if ( ! IsUnoAssembly && ! IsUnoFluentAssembly )
720
722
{
721
723
// For third-party libraries, expose all files using standard uri
722
724
foreach ( var file in files . Where ( IsResourceDictionary ) )
@@ -738,7 +740,7 @@ private string GenerateGlobalResources(IEnumerable<XamlFileDefinition> files, Xa
738
740
void RegisterForFile ( string baseFilePath , string url )
739
741
{
740
742
var file = files . FirstOrDefault ( f =>
741
- f . FilePath . Substring ( _projectDirectory . Length + 1 ) . Equals ( baseFilePath , StringComparison . OrdinalIgnoreCase ) ) ;
743
+ f . FilePath . Substring ( _projectDirectory . Length + 1 ) . Equals ( baseFilePath , StringComparison . OrdinalIgnoreCase ) ) ;
742
744
743
745
if ( file != null )
744
746
{
@@ -766,10 +768,12 @@ void RegisterForXamlFile(XamlFileDefinition file, string url)
766
768
foreach ( var file in files . Where ( IsResourceDictionary ) )
767
769
{
768
770
// We leave context null because local resources should be found through Application.Resources
769
- writer . AppendLineInvariant ( "global::Uno.UI.ResourceResolver.RegisterResourceDictionaryBySource(uri: \" {0}{1}\" , context: null, dictionary: () => {2}_ResourceDictionary);" ,
771
+ writer . AppendLineInvariant ( "global::Uno.UI.ResourceResolver.RegisterResourceDictionaryBySource(uri: \" {0}{1}\" , context: null, dictionary: () => {2}_ResourceDictionary, {3} );" ,
770
772
XamlFilePathHelper . LocalResourcePrefix ,
771
773
map . GetSourceLink ( file ) ,
772
- file . UniqueID
774
+ file . UniqueID ,
775
+ // Make ResourceDictionary retrievable by Hot Reload
776
+ _isDebug ? $ "\" { file . FilePath . Replace ( "\\ " , "/" ) } \" " : "null"
773
777
) ;
774
778
// Local resources can also be found through the ms-appx:/// prefix
775
779
writer . AppendLineInvariant ( "global::Uno.UI.ResourceResolver.RegisterResourceDictionaryBySource(uri: \" {0}{1}\" , context: null, dictionary: () => {2}_ResourceDictionary);" ,
@@ -789,7 +793,7 @@ void RegisterForXamlFile(XamlFileDefinition file, string url)
789
793
790
794
// Generate all the partial methods, even if they don't exist. That avoids
791
795
// having to sync the generation of the files with this global table.
792
- foreach ( var file in files . Select ( f=> f . UniqueID ) . Distinct ( ) )
796
+ foreach ( var file in files . Select ( f => f . UniqueID ) . Distinct ( ) )
793
797
{
794
798
writer . AppendLineInvariant ( "static partial void RegisterDefaultStyles_{0}();" , file ) ;
795
799
}
0 commit comments