void ApplyFieldAttributes() { //.Run mode doesn't go through the jobsystem, so there's no point in making all these attributes to explain the job system what everything means. if (LambdaJobDescriptionConstruction.ExecutionMode == ExecutionMode.Run) { return; } foreach (var(methodName, attributeType) in ConstructionMethodsThatCorrespondToFieldAttributes) { foreach (var constructionMethod in LambdaJobDescriptionConstruction.InvokedConstructionMethods.Where(m => m.MethodName == methodName)) { if (constructionMethod.Arguments.Single() is FieldDefinition fieldDefinition) { var correspondingJobField = ClonedFields.Values.Single(f => f.Name == fieldDefinition.Name); correspondingJobField.CustomAttributes.Add(new CustomAttribute(TypeDefinition.Module.ImportReference(attributeType.GetConstructor(Array.Empty <Type>())))); continue; } UserError.DC0012(LambdaJobDescriptionConstruction.ContainingMethod, constructionMethod).Throw(); } } }