Esempio n. 1
0
        // Internal for testing
        internal void Publish(ProjectSnapshot projectSnapshot)
        {
            if (projectSnapshot is null)
            {
                throw new ArgumentNullException(nameof(projectSnapshot));
            }

            lock (_publishLock)
            {
                string publishFilePath = null;
                try
                {
                    if (!PublishFilePathMappings.TryGetValue(projectSnapshot.FilePath, out publishFilePath))
                    {
                        return;
                    }

                    SerializeToFile(projectSnapshot, publishFilePath);
                }
                catch (Exception ex)
                {
                    _logger.LogWarning($@"Could not update Razor project configuration file '{publishFilePath}':
{ex}");
                }
            }
        }
Esempio n. 2
0
        // Internal for testing
        internal void Publish(ProjectSnapshot projectSnapshot)
        {
            if (projectSnapshot is null)
            {
                throw new ArgumentNullException(nameof(projectSnapshot));
            }

            lock (_publishLock)
            {
                string configurationFilePath = null;
                try
                {
                    if (!_projectConfigurationFilePathStore.TryGet(projectSnapshot.FilePath, out configurationFilePath))
                    {
                        return;
                    }

                    // We don't want to serialize the project until it's ready to avoid flashing as the project loads different parts.
                    // Since the project.razor.json from last session likely still exists the experience is unlikely to be degraded by this delay.
                    // An exception is made for when there's no existing project.razor.json because some flashing is preferable to having no TagHelper knowledge.
                    if (ShouldSerialize(configurationFilePath))
                    {
                        SerializeToFile(projectSnapshot, configurationFilePath);
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogWarning($@"Could not update Razor project configuration file '{configurationFilePath}':
{ex}");
                }
            }
        }