Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove non-working caching unmodified xaml files #12589

Merged
merged 5 commits into from
Jun 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ internal partial class XamlCodeGeneration

private readonly Uno.Roslyn.MSBuildItem[] _xamlSourceFiles;
private readonly string[] _xamlSourceLinks;
private readonly string _targetPath;
private readonly string _defaultLanguage;
private readonly bool _isWasm;
private readonly bool _isDesignTimeBuild;
Expand Down Expand Up @@ -241,11 +240,6 @@ public XamlCodeGeneration(GeneratorExecutionContext context)
_enableFuzzyMatching = true;
}

_targetPath = Path.Combine(
_projectDirectory,
context.GetMSBuildPropertyValue("IntermediateOutputPath")
);

_defaultLanguage = context.GetMSBuildPropertyValue("DefaultLanguage");

_uiAutomationMappings = context.GetMSBuildItemsWithAdditionalFiles("CustomUiAutomationMemberMappingAdjusted")
Expand Down Expand Up @@ -434,7 +428,6 @@ public List<KeyValuePair<string, SourceText>> Generate(GenerationRunInfo generat
new XamlFileGenerator(
this,
file: file,
targetPath: _targetPath,
defaultNamespace: _defaultNamespace,
metadataHelper: _metadataHelper,
fileUniqueId: file.UniqueID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ internal partial class XamlFileGenerator
private int _resourceOwner;
private readonly XamlFileDefinition _fileDefinition;
private readonly NamespaceDeclaration _defaultXmlNamespace;
private readonly string _targetPath;
private readonly string _defaultNamespace;
private readonly RoslynMetadataHelper _metadataHelper;
private readonly string _fileUniqueId;
Expand All @@ -81,7 +80,6 @@ internal partial class XamlFileGenerator
private readonly bool _isHotReloadEnabled;
private readonly bool _isInsideMainAssembly;
private readonly bool _isDesignTimeBuild;
private readonly string _relativePath;
private readonly bool _useXamlReaderHotReload;

/// <summary>
Expand Down Expand Up @@ -193,7 +191,6 @@ internal partial class XamlFileGenerator
public XamlFileGenerator(
XamlCodeGeneration generation,
XamlFileDefinition file,
string targetPath,
string defaultNamespace,
RoslynMetadataHelper metadataHelper,
string fileUniqueId,
Expand Down Expand Up @@ -225,7 +222,6 @@ public XamlFileGenerator(
{
Generation = generation;
_fileDefinition = file;
_targetPath = targetPath;
_defaultNamespace = defaultNamespace;
_metadataHelper = metadataHelper;
_fileUniqueId = fileUniqueId;
Expand Down Expand Up @@ -253,7 +249,6 @@ public XamlFileGenerator(

InitCaches();

_relativePath = PathHelper.GetRelativePath(_targetPath, _fileDefinition.FilePath);
ShouldWriteErrorOnInvalidXaml = shouldWriteErrorOnInvalidXaml;

_isWasm = isWasm;
Expand All @@ -276,35 +271,6 @@ public SourceText GenerateFile()
Console.WriteLine("Processing file {0}".InvariantCultureFormat(_fileDefinition.FilePath));
#endif

// Check for the Roslyn generator's output location
var outputFile = Path.Combine(
_targetPath,
$@"g\{typeof(XamlCodeGenerator).Name}\{_fileDefinition.UniqueID}.g.cs"
);

if (File.Exists(outputFile))
{
var outputInfo = new FileInfo(outputFile);
var inputInfo = new FileInfo(_fileDefinition.FilePath);

if (
outputInfo.LastWriteTime >= inputInfo.LastWriteTime

// Check for the references update time. If the file has been generated before the last write time
// on the references, regenerate the output.
&& outputInfo.LastWriteTime > _lastReferenceUpdateTime

// Empty files should be regenerated
&& outputInfo.Length != 0
)
{
#if DEBUG
Console.WriteLine("Skipping unmodified file {0}".InvariantCultureFormat(_fileDefinition.FilePath));
#endif
return SourceText.From(File.ReadAllText(outputFile), Encoding.UTF8);
}
}

try
{
return InnerGenerateFile();
Expand Down Expand Up @@ -667,7 +633,7 @@ void ApplyLiteralProperties()
{
blockWriter.AppendLineInvariantIndented(
"// Source {0} (Line {1}:{2})",
_relativePath,
_fileDefinition.TargetFilePath,
topLevelControl.LineNumber,
topLevelControl.LinePosition
);
Expand Down Expand Up @@ -876,7 +842,7 @@ private void BuildGenericControlInitializerBody(IndentedStringBuilder writer, Xa
{
blockWriter.AppendLineInvariantIndented(
"// Source {0} (Line {1}:{2})",
_relativePath,
_fileDefinition.TargetFilePath,
topLevelControl.LineNumber,
topLevelControl.LinePosition
);
Expand Down Expand Up @@ -1699,7 +1665,7 @@ private void BuildSourceLineInfo(IIndentedStringBuilder writer, XamlObjectDefini
TryAnnotateWithGeneratorSource(writer);
writer.AppendLineInvariantIndented(
"// Source {0} (Line {1}:{2})",
_relativePath,
_fileDefinition.TargetFilePath,
definition.LineNumber,
definition.LinePosition
);
Expand Down