public void Is() { Assert.ThrowsAny <Exception>(() => Assumes.Is <string>(null)); Assert.ThrowsAny <Exception>(() => Assumes.Is <string>(45)); Assert.ThrowsAny <Exception>(() => Assumes.Is <string>(new object())); Assumes.Is <string>("hi"); }
public int ReadSolutionProps(IVsHierarchy pHierarchy, string pszProjectName, string pszProjectMk, string pszKey, int fPreLoad, IPropertyBag pPropBag) { ThreadHelper.ThrowIfNotOnUIThread(); if (pHierarchy == null) { if (PackageGuidString.Equals(pszKey, StringComparison.OrdinalIgnoreCase)) { object propertyValue; pPropBag.Read("PropertyName", out propertyValue, null, (uint)VarEnum.VT_BSTR, pPropBag); Assumes.Is <string>(propertyValue); Assumes.Equals("PropertyValue", (string)propertyValue); } } return(VSConstants.S_OK); }
private void TextDocument_FileActionOccurred(object sender, TextDocumentFileActionEventArgs args) { if (args.FileActionType != FileActionTypes.ContentSavedToDisk) { return; } Assumes.Is <ITextDocument>(sender); UIThreadHelper.VerifyOnUIThread(); var textDocument = (ITextDocument)sender; var savedText = textDocument.TextBuffer.CurrentSnapshot.GetText(); _threadingService.ExecuteSynchronously(() => _msbuildAccessor.RunLockedAsync(true, () => { _fileSystem.WriteAllText(_unconfiguredProject.FullPath, savedText); return(Task.CompletedTask); })); }
public static IEnumerable <TGenerator> LoadCodeGenerators <TGenerator>(this ImmutableArray <AttributeData> attributeData, LoadAssemblyCallback loader) where TGenerator : class, ICodeGenerator { Requires.NotNull(loader, nameof(loader)); TGenerator CreateCodeGenerator(GeneratorTuple tuple) { var(generatorType, datum) = tuple; var generator = Activator.CreateInstance(generatorType, datum); Requires.NotNull(generator, nameof(generator)); // TODO: TBD: might be better if .Is<T> actually returned T... i.e. could simple `return Assumes.Is<ICodeGenerator>(generator);´ Assumes.Is <TGenerator>(generator); return((TGenerator)generator); } return(attributeData .Select(x => GeneratorTuple.Create(x.AttributeClass.GetCodeGeneratorTypeForAttribute(loader), x)) .Where(tuple => tuple.GeneratorType != null).Select(CreateCodeGenerator)); }