Last active
July 9, 2017 22:15
-
-
Save dbremner/3d8c90375730888c53d5df3308937e74 to your computer and use it in GitHub Desktop.
using ReSharper annotations for a TryParse workalike
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//taken from https://resharper-support.jetbrains.com/hc/en-us/community/posts/206650785-Can-I-handle-not-initialized-warnings-with-Jetbrains-Annotations- | |
[ContractAnnotation("=> false, target:null; => true, target:notnull")] | |
private bool TryFindWorkbook([NotNull] Excel.Workbooks workbooks, [CanBeNull] out Excel.Workbook target) | |
{ | |
Requires.NotNull(workbooks, nameof(workbooks)); | |
foreach (Excel.Workbook workbook in workbooks) | |
{ | |
if (workbook.Name == cellLocation.WorkBookName) | |
{ | |
target = workbook; | |
return true; | |
} | |
} | |
target = null; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment