public static void RegisterVSInternalExtensionConverters(this LspSerializer serializer) { if (serializer is null) { throw new ArgumentNullException(nameof(serializer)); } // In all of the below we add our converters to both the serializer settings and the actual // JsonSerializer. The reasoning behind this choice is that OmniSharp framework is not consistent // in using one over the other so we want to protect ourselves. // We create a temporary serializer because the VS API's only have extension methods for adding converters to the top-level serializer type; therefore, // we effectively create a bag that the VS APIs can add to and then extract the added converters to add to the LSP serializer. var tempSerializer = new JsonSerializer(); tempSerializer.Converters.Clear(); tempSerializer.AddVSInternalExtensionConverters(); var converters = tempSerializer.Converters; for (var i = 0; i < converters.Count; i++) { AddConverter(serializer, converters[i]); } }
public DefaultLSPRequestInvoker( ILanguageServiceBroker2 languageServiceBroker, FallbackCapabilitiesFilterResolver fallbackCapabilitiesFilterResolver) { if (languageServiceBroker is null) { throw new ArgumentNullException(nameof(languageServiceBroker)); } if (fallbackCapabilitiesFilterResolver is null) { throw new ArgumentNullException(nameof(fallbackCapabilitiesFilterResolver)); } _languageServiceBroker = languageServiceBroker; _fallbackCapabilitiesFilterResolver = fallbackCapabilitiesFilterResolver; // We need these converters so we don't lose information as part of the deserialization. _serializer = new JsonSerializer(); _serializer.AddVSInternalExtensionConverters(); }