diff options
author | Sven Boemer <sbomer@gmail.com> | 2021-10-19 21:42:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-19 21:42:12 +0300 |
commit | 4c9de67922b2381aed29c6dff2c892ff6467f114 (patch) | |
tree | 6ba7c46cab304cae9a2a2107b3e0b050b16613f7 /src/linker/Linker.Steps/BaseSubStep.cs | |
parent | c75a5240bd253e2e407438cbaa14c9d1bf714343 (diff) |
Nullable annotations part 4 (final) (#2300)
* Nullable annotations part 4 (final)
* PR feedback
- Clean up extra variables introduced as
nullable versions of existing variables.
* Fix a few annotations
- TryGetMethodStubValue may return null when true
- GetReturnType and GetParameterType may return null in some cases
* More annotations and PR feedback
- Don't resolve a generic typeref that should already be a typedef
- Remove some redundant null checks
- Turn on nullable annotations for ref assembly
- Remove #nullable disable section
* Clean up GetInflatedDeclaringType
- Remove null check
- Replace TryResolve call with an assert
- Add comment and asserts justifying null-forgiving operator
* Replace exception with assert in accessors
* PR feedback
- Add parens to improve readability
- Throw on diagnostic without message
- Remove unnecessary string.empty
* Undo DiagnosticString change
- Some DiagnosticIds intentionally have no fixed format strings because
we generate different strings in different circumstances.
Diffstat (limited to 'src/linker/Linker.Steps/BaseSubStep.cs')
-rw-r--r-- | src/linker/Linker.Steps/BaseSubStep.cs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/linker/Linker.Steps/BaseSubStep.cs b/src/linker/Linker.Steps/BaseSubStep.cs index 9a3aa250a..4826c7014 100644 --- a/src/linker/Linker.Steps/BaseSubStep.cs +++ b/src/linker/Linker.Steps/BaseSubStep.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; +using System.Diagnostics; using Mono.Cecil; namespace Mono.Linker.Steps @@ -9,13 +11,19 @@ namespace Mono.Linker.Steps { protected AnnotationStore Annotations => Context.Annotations; - protected LinkContext Context { get; private set; } + LinkContext? _context { get; set; } + protected LinkContext Context { + get { + Debug.Assert (_context != null); + return _context; + } + } public abstract SubStepTargets Targets { get; } public virtual void Initialize (LinkContext context) { - Context = context; + _context = context; } public virtual bool IsActiveFor (AssemblyDefinition assembly) => true; |