示例#1
0
        private void WriteSettingsToSharedMemory(CodeAnalysisSettings codeAnalysisSettings)
        {
            using MemoryMappedViewStream stream           = _memoryMappedFile.CreateViewStream();
            using CodeAnalysisSettingsBinaryWriter writer = new CodeAnalysisSettingsBinaryWriter(stream);

            writer.WriteCodeAnalysisSettings(codeAnalysisSettings);
        }
        public void CheckCodeAnalysisSettingsSerialization(bool recursiveAnalysisEnabled, bool isvSpecificAnalyzersEnabled, bool staticAnalysisEnabled,
                                                           bool suppressionMechanismEnabled, bool px1007DocumentationDiagnosticEnabled)
        {
            var expectedSettings = new CodeAnalysisSettings(recursiveAnalysisEnabled, isvSpecificAnalyzersEnabled,
                                                            staticAnalysisEnabled, suppressionMechanismEnabled,
                                                            px1007DocumentationDiagnosticEnabled);

            using var stream = new MemoryStream(capacity: sizeof(bool) * 5 + 20);
            using var writer = new CodeAnalysisSettingsBinaryWriter(stream);

            writer.WriteCodeAnalysisSettings(expectedSettings);

            stream.Position = 0;

            using var reader = new CodeAnalysisSettingsBinaryReader(stream);
            var deserializedSettings = reader.ReadCodeAnalysisSettings();

            Assert.Equal(deserializedSettings, expectedSettings);
        }