Пример #1
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}");
                }
            }
        }
Пример #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;
                    }

                    SerializeToFile(projectSnapshot, configurationFilePath);
                }
                catch (Exception ex)
                {
                    _logger.LogWarning($@"Could not update Razor project configuration file '{configurationFilePath}':
{ex}");
                }
            }
        }