How to set rules for generic type parameters in VisualStudio? - visual-studio-2017

The picture below shows the warning I keep getting in Visual Studio 2017:
I got this off some website and I have tried all sorts of things. Does anyone know how I can get rid of this?
Here is my the part of my .editorconfig related to naming:
###############################
# Naming Conventions #
###############################
# Style Definitions
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
dotnet_naming_style.camel_case_style.capitalization = camel_case
dotnet_naming_style.I_prefix_style.required_prefix = I
dotnet_naming_style.I_prefix_style.capitalization = pascal_case
# Use PascalCase for constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = warning
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
dotnet_naming_symbols.constant_fields.required_modifiers = const
# Use PascalCase for public fields
dotnet_naming_rule.pascal_case_for_public_fields.severity = warning
dotnet_naming_rule.pascal_case_for_public_fields.symbols = public_fields
dotnet_naming_rule.pascal_case_for_public_fields.style = pascal_case_style
dotnet_naming_symbols.public_fields.applicable_kinds = field
dotnet_naming_symbols.public_fields.applicable_accessibilities = public
# Interfaces must be PascalCase and have an I prefix
dotnet_naming_rule.interfaces_start_with_I.severity = warning
dotnet_naming_rule.interfaces_start_with_I.symbols = any_interface
dotnet_naming_rule.interfaces_start_with_I.style = I_prefix_style
dotnet_naming_symbols.any_interface.applicable_accessibilities = *
dotnet_naming_symbols.any_interface.applicable_kinds = interface
# Classes, structs, methods, enums, events, properties, namespaces, delegates must be PascalCase
dotnet_naming_rule.general_naming.severity = warning
dotnet_naming_rule.general_naming.symbols = general
dotnet_naming_rule.general_naming.style = pascal_case_style
dotnet_naming_symbols.general.applicable_kinds = class,struct,enum,property,method,event,namespace,delegate
dotnet_naming_symbols.general.applicable_accessibilities = *
# Everything else is camelCase
dotnet_naming_rule.everything_else_naming.severity = warning
dotnet_naming_rule.everything_else_naming.symbols = everything_else
dotnet_naming_rule.everything_else_naming.style = camel_case_style
dotnet_naming_symbols.everything_else.applicable_kinds = *
dotnet_naming_symbols.everything_else.applicable_accessibilities = *

# prefix_type_parameters_with_t_style - Generic Type Parameters must be PascalCase and the first character must be a 'T'
dotnet_naming_style.prefix_type_parameters_with_t_style.capitalization = pascal_case
dotnet_naming_style.prefix_type_parameters_with_t_style.required_prefix = T
You can get nice set of rules from here.

Related

How to call AWS Cloudfront Update-CFDistribution Powershell Cmdlet

I have written the script to change the origin path" of a specific origin on a specific distribution in CloudFront. After changing the path I am getting errors when trying to update the distribution with the changes. I do not want to change anything else on the distribution besides the "origin path", so how do I call Update-CFDistribution to make these changes ideally without having to set every parameter (future updates to the API may cause this script to fail or even worst make incomplete modifications)?
$distributions = Get-CFDistributionList
foreach($distribution in $distributions) {
if($distribution.Id -eq "$CloudfrontDistributionId") {
foreach ($origin in $distribution.Origins) {
foreach($item in $origin.Items) {
if($item.Id -eq "OriginName") {
$item.OriginPath = "/$($S3BucketPrefix)"
Update-CFDistribution -Id $CloudfrontDistributionId -Origins_Item #($item)
}
}
}
}
}
Error
InvalidOperation: 5 validation errors detected: Value null at
'distributionConfig.defaultCacheBehavior' failed to satisfy
constraint: Member must not be null; Value null at
'distributionConfig.enabled' failed to satisfy constraint: Member must
not be null; Value null at 'distributionConfig.callerReference' failed
to satisfy constraint: Member must not be null; Value null at
'distributionConfig.origins.quantity' failed to satisfy constraint:
Member must not be null; Value at 'distributionConfig.comment' failed
to satisfy constraint: Member must not be null
I don't have the reputation to add just a comment so I'm having to put this as an answer, but it's better suited as a comment.
According to the documentation, there are a number of required fields when you issue an update, even if you're only trying to update one thing:
https://docs.aws.amazon.com/powershell/latest/reference/items/Update-CFDistribution.html
When you update a distribution, there are more required fields than
when you create a distribution. When you update your distribution by
using this API action, follow the steps here to get the current
configuration and then make your updates, to make sure that you
include all of the required fields.
I had the same issue and asked about it on the aws-tools-for-powershell Q&A. As far as I can tell, the answer is you just have to map all the properties. I took the time to do that today. In other PowerShell module contexts, I would expect you'd be able to just pipe in the object from a Get call with changes into an Update call and it would handle the parameter bindings. That doesn't work in this context. This is a known issue for a lot of aws-tools-for-powershell cmdlets according to aws-tools-for-powershell Issue #214.
Below is a snippet of the 66 mappings required to ensure you're updating all properties exactly as they were handed to you in the original Get call. It's possible fewer are actually required, but given I want an exact copy it felt safer to ensure all the data was available and let the API decide what could be dropped.
The etag thing is from: AWS PowerShell update CloudFront distribution
$distribution = Get-CFDistribution -Id $distributionFromList.Id
$etag = $AWSHistory.LastServiceResponse.ETag
$params = #{
Id = $distribution.Id
Verbose = $true
IfMatch = $etag
Aliases_Item = $distribution.DistributionConfig.Aliases.Items
Aliases_Quantity = $distribution.DistributionConfig.Aliases.Quantity
AllowedMethods_Item = $distribution.DistributionConfig.DefaultCacheBehavior.AllowedMethods.Items
AllowedMethods_Quantity = $distribution.DistributionConfig.DefaultCacheBehavior.AllowedMethods.Quantity
CacheBehaviors_Item = $distribution.DistributionConfig.CacheBehaviors.Items
CacheBehaviors_Quantity = $distribution.DistributionConfig.CacheBehaviors.Quantity
CachedMethods_Item = $distribution.DistributionConfig.DefaultCacheBehavior.AllowedMethods.CachedMethods.Items
CachedMethods_Quantity = $distribution.DistributionConfig.DefaultCacheBehavior.AllowedMethods.CachedMethods.Quantity
Cookies_Forward = $distribution.DistributionConfig.DefaultCacheBehavior.ForwardedValues.Cookies.Forward
CustomErrorResponses_Item = $distribution.DistributionConfig.CustomErrorResponses.Items
CustomErrorResponses_Quantity = $distribution.DistributionConfig.CustomErrorResponses.Quantity
DefaultCacheBehavior_CachePolicyId = $distribution.DistributionConfig.DefaultCacheBehavior.CachePolicyId
DefaultCacheBehavior_Compress = $distribution.DistributionConfig.DefaultCacheBehavior.Compress
DefaultCacheBehavior_DefaultTTL = $distribution.DistributionConfig.DefaultCacheBehavior.DefaultTTL
DefaultCacheBehavior_FieldLevelEncryptionId = $distribution.DistributionConfig.DefaultCacheBehavior.FieldLevelEncryptionId
DefaultCacheBehavior_MaxTTL = $distribution.DistributionConfig.DefaultCacheBehavior.MaxTTL
DefaultCacheBehavior_MinTTL = $distribution.DistributionConfig.DefaultCacheBehavior.MinTTL
DefaultCacheBehavior_OriginRequestPolicyId = $distribution.DistributionConfig.DefaultCacheBehavior.OriginRequestPolicyId
DefaultCacheBehavior_RealtimeLogConfigArn = $distribution.DistributionConfig.DefaultCacheBehavior.RealtimeLogConfigArn
DefaultCacheBehavior_ResponseHeadersPolicyId = $distribution.DistributionConfig.DefaultCacheBehavior.ResponseHeadersPolicyId
DefaultCacheBehavior_SmoothStreaming = $distribution.DistributionConfig.DefaultCacheBehavior.SmoothStreaming
DefaultCacheBehavior_TargetOriginId = $distribution.DistributionConfig.DefaultCacheBehavior.TargetOriginId
DefaultCacheBehavior_ViewerProtocolPolicy = $distribution.DistributionConfig.DefaultCacheBehavior.ViewerProtocolPolicy
DistributionConfig_CallerReference = $distribution.DistributionConfig.CallerReference
DistributionConfig_Comment = $distribution.DistributionConfig.Comment
DistributionConfig_DefaultRootObject = $distribution.DistributionConfig.DefaultRootObject
DistributionConfig_Enabled = $distribution.DistributionConfig.Enabled
DistributionConfig_HttpVersion = $distribution.DistributionConfig.HttpVersion
DistributionConfig_IsIPV6Enabled = $distribution.DistributionConfig.IsIPV6Enabled
DistributionConfig_PriceClass = $distribution.DistributionConfig.PriceClass
DistributionConfig_WebACLId = $distribution.DistributionConfig.WebACLId
ForwardedValues_QueryString = $distribution.DistributionConfig.DefaultCacheBehavior.ForwardedValues.QueryString
FunctionAssociations_Item = $distribution.DistributionConfig.DefaultCacheBehavior.FunctionAssociations.Items
FunctionAssociations_Quantity = $distribution.DistributionConfig.DefaultCacheBehavior.FunctionAssociations.Quantity
GeoRestriction_Item = $distribution.DistributionConfig.Restrictions.GeoRestriction.Items
GeoRestriction_Quantity = $distribution.DistributionConfig.Restrictions.GeoRestriction.Quantity
GeoRestriction_RestrictionType = $distribution.DistributionConfig.Restrictions.GeoRestriction.RestrictionType
Headers_Item = $distribution.DistributionConfig.DefaultCacheBehavior.ForwardedValues.Headers.Items
Headers_Quantity = $distribution.DistributionConfig.DefaultCacheBehavior.ForwardedValues.Headers.Quantity
LambdaFunctionAssociations_Item = $distribution.DistributionConfig.DefaultCacheBehavior.LambdaFunctionAssociations.Items
LambdaFunctionAssociations_Quantity = $distribution.DistributionConfig.DefaultCacheBehavior.LambdaFunctionAssociations.Quantity
Logging_Bucket = $distribution.DistributionConfig.Logging.Bucket
Logging_Enabled = $distribution.DistributionConfig.Logging.Enabled
Logging_IncludeCookie = $distribution.DistributionConfig.Logging.IncludeCookies
Logging_Prefix = $distribution.DistributionConfig.Logging.Prefix
OriginGroups_Item = $distribution.DistributionConfig.OriginGroups.Items
OriginGroups_Quantity = $distribution.DistributionConfig.OriginGroups.Quantity
Origins_Item = $distribution.DistributionConfig.Origins.Items
Origins_Quantity = $distribution.DistributionConfig.Origins.Quantity
QueryStringCacheKeys_Item = $distribution.DistributionConfig.DefaultCacheBehavior.ForwardedValues.QueryStringCacheKeys.Items
QueryStringCacheKeys_Quantity = $distribution.DistributionConfig.DefaultCacheBehavior.ForwardedValues.QueryStringCacheKeys.Quantity
TrustedKeyGroups_Enabled = $distribution.DistributionConfig.DefaultCacheBehavior.TrustedKeyGroups.Enabled
TrustedKeyGroups_Item = $distribution.DistributionConfig.DefaultCacheBehavior.TrustedKeyGroups.Items
TrustedKeyGroups_Quantity = $distribution.DistributionConfig.DefaultCacheBehavior.TrustedKeyGroups.Quantity
TrustedSigners_Enabled = $distribution.DistributionConfig.DefaultCacheBehavior.TrustedSigners.Enabled
TrustedSigners_Item = $distribution.DistributionConfig.DefaultCacheBehavior.TrustedSigners.Items
TrustedSigners_Quantity = $distribution.DistributionConfig.DefaultCacheBehavior.TrustedSigners.Quantity
ViewerCertificate_ACMCertificateArn = $distribution.DistributionConfig.ViewerCertificate.ACMCertificateArn
ViewerCertificate_Certificate = $distribution.DistributionConfig.ViewerCertificate.Certificate
ViewerCertificate_CertificateSource = $distribution.DistributionConfig.ViewerCertificate.CertificateSource
ViewerCertificate_CloudFrontDefaultCertificate = $distribution.DistributionConfig.ViewerCertificate.CloudFrontDefaultCertificate
ViewerCertificate_IAMCertificateId = $distribution.DistributionConfig.ViewerCertificate.IAMCertificateId
ViewerCertificate_MinimumProtocolVersion = $distribution.DistributionConfig.ViewerCertificate.MinimumProtocolVersion
ViewerCertificate_SSLSupportMethod = $distribution.DistributionConfig.ViewerCertificate.SSLSupportMethod
WhitelistedNames_Item = $distribution.DistributionConfig.DefaultCacheBehavior.ForwardedValues.Cookies.WhitelistedNames.Items
WhitelistedNames_Quantity = $distribution.DistributionConfig.DefaultCacheBehavior.ForwardedValues.Cookies.WhitelistedNames.Quantity
}
Update-CFDistribution #params -WhatIf

Backend Layout in TS file in TYPO3 CMS 7.6.18 how to get it working?

To be able to use different templates in a TYPO3 CMS 7.6.18 setup. I include a pageTSConfig.ts file with a backend layout looking like this. (see also this pastebin: https://pastebin.com/BcYKrYKh and this how it looks like in the TYPO3 object browser: https://pastebin.com/LVXqNUZC
### Backend Layouts #####
mod.web_layout.BackendLayouts{
1 {
title = Standaard Layout
config {
backend_layout {
colCount = 2
rowCount = 1
rows {
1 {
columns {
1 {
name = linker_inhoud
colPos = 1
}
2 {
name = midden_inhoud
colPos = 0
}
}
}
}
}
}
}
}
Since the BE-Layout is done with a file, in my TSconfig.ts I have added pagets__0 to it like the manual mentioned. Still this is not working. What Am I missing here? This is a part of the TSconfig I have in place here is the complete config:
page.10.file.stdWrap.cObject = CASE
page.10.file.stdWrap.cObject {
key.data = levelfield:-1, backend_layout_next_level, pagelayout, slide
key.override.field = pagelayout
default = TEXT
default.value = fileadmin/templates/index.html
pagets__0 = TEXT
pagets__0.value = fileadmin/templates/index.html
pagets__1 = TEXT
pagets__1.value = fileadmin/templates/layouts/small_header_page.html
pagets__2 = TEXT
pagets__2.value = fileadmin/templates/layouts/alternatieve_pagina.html
}
All to be included with:
There is a difference between "backend_layout", which is a the name of a real database field that can be fetched by "levelfield" and "pagelayout", which is a kind of virtual field to get rid of the "levelfield" approach.
https://docs.typo3.org/typo3cms/TyposcriptReference/DataTypes/Gettext/Index.html#pagelayout
key.data = pagelayout
should do the whole job for you and only in this case you can use stuff like
pagets__x
to access the actual layout.
So your code should either be:
page.10 = FLUIDTEMPLATE
page.10.file.cObject = CASE
page.10.file.cObject {
key.data = pagelayout
default = TEXT
default.value = fileadmin/templates/index.html
pagets__0 = TEXT
pagets__0.value = fileadmin/templates/index.html
pagets__1 = TEXT
pagets__1.value = fileadmin/templates/layouts/small_header_page.html
pagets__2 = TEXT
pagets__2.value = fileadmin/templates/layouts/alternatieve_pagina.html
}
or it should be
page.10 = FLUIDTEMPLATE
page.10.file.cObject = CASE
page.10.file.cObject {
key.data = levelfield:-1, backend_layout_next_level, slide
key.override.field = backend_layout
default = TEXT
default.value = fileadmin/templates/index.html
1 = TEXT
1.value = fileadmin/templates/layouts/small_header_page.html
2 = TEXT
2.value = fileadmin/templates/layouts/alternatieve_pagina.html
}
But not a mix of both approaches.
Before I tell you what might be wrong with your code, let me explain you a few things.
You have placed your templates in the fileadmin directory. This is not the place where to put these files any longer, because the fileadmin is a public place for resources like images, videos or documents. It might be available for every backend user in the filelist and the editor should not be able to edit the template in any case. The suggested way to handle your templates is to put them into an own extension that can be installed via the extension manager.
In your pastebin snippets, there is a line with userFunc = tx_templavoila_pi1->main_page, you may mixing up stuff in your installation and don't want to use FLUIDTEMPLATE alongside templavoila, because it could be confusing what rendering method is used for what stuff on your page. Better stick to templavoila or Fluid for the entirety of the TYPO3 installation.
Now, you have these lines in your TypoScript:
key.data = levelfield:-1, backend_layout_next_level, pagelayout, slide
key.override.field = pagelayout
There is no field pagelayout in the pages records. The field you rather want to address is backend_layout.

Access instance variable from instance method in python

class SimpleBond(object):
def__init__(self,OriginationDate,SettleDate,Coupon,CouponFreq,Maturity,Par,StartingPrice = None):
self.CouponCFDaysFromOrigination = np.arange(1,self.NumCouponCFs + 1) * self.CashFlowDelta
self.OriginationCashFlowDates = np.array([self.StartDate + np.timedelta64(int(i),'D') for i in self.CouponCFDaysFromOrigination])
self.StartDate = OriginationDate
def GenerateCashFlowsAndDates(self):
CashFlowDates = self.OriginationCashFlowDates
self.CashFlowDates = CashFlowDates[(CashFlowDates >= self.SettleDate) & (CashFlowDates <=self.MaturityDate)]
I have a class definition as above. Some where else I instantiate the class as below:
BondObj = SimpleBond(OriginationDate = InceptionDate,SettleDate= np.datetime64('2008-02-15'),Coupon = 8.875,CouponFreq = 2,Maturity = 9.5,Par = 100.)
BondObj.GenerateCashFlowsAndDates()
The issue is with the call to GenerateCashFlowDates() as shown above, Once the BondObj is assigned to an instantiation of the SimpleBond class with the arguments to set the state.
When I step inside the call BondObj.GenerateCashFlowsAndDates()....I can see the following state variables
self.StartDate.....its shows the actual state
where
self.OriginationCashFlowDates shows no value. It is none
As a matter of fact, all other instance variables that were set in the constructor are visible from BondObj.GenerateCashFlowAndDates() call
Many thanks

lxml ns_clean=True does not appear to work

The following code:
NAMESPACES = {'ns': 'http://www.starstandard.org/STAR/5', 'ns1': 'http://www.openapplications.org/oagis/9'}
ro_xml = '{}.xml'.format(6001265)
parser = etree.XMLParser(ns_clean=True)
tree = etree.parse(ro_xml)
root = etree.tostring(tree.getroot())
# print root
residence = []
residence_address = '//ns:ResidenceAddress/*'
shop_supplies_amount = tree.xpath(residence_address, namespaces=NAMESPACES)
for child in shop_supplies_amount:
residence.append("%s: %s" % (child.tag, child.text))
print residence
When I run this I am getting the namespaces in front of the tag names like so '{http://www.starstandard.org/STAR/5}LineOne: 10757 RIVER FRONT PARKWAY'
What am I doing incorrectly and how do I get rid of the namespace in front of the tag names
I figured a way around it.
NAMESPACES = {'ns': 'http://www.starstandard.org/STAR/5', 'ns1': 'http://www.openapplications.org/oagis/9'}
ro_xml = '{}.xml'.format(6001265)
parser = etree.XMLParser(ns_clean=True)
tree = etree.parse(ro_xml, parser)
vehicle = {}
vehicle_info = tree.xpath(twc.XML_VEHICLE_INFO, namespaces=NAMESPACES)
for child in vehicle_info:
vehicle.update({child.tag: child.text})
model = residence['{%s}Model' % NAMESPACES['ns']]
print model
Not the cleanest I admit, but it gets me where I need to be.

Django: Simplifying long 'join's?

I've got a few long queries (for checking capabilities) which look like this:
widgets = Widget.objects.filter(
Q(owner__memberships = current_user),
Q(owner__memberships__memberships__capabilities__name = "widget_list")
)
Is there any reasonable way of simplifying that query? Or do I just need to live with it?
The relevant models are:
class Widget(m.Model):
owner = m.ForeignKey(Group)
class Group(m.Model):
memberships = m.ManyToManyField(User, through=GroupMembership)
class GroupMembership(m.Model):
user = m.ForeignKey(User)
group = m.ForeignKey(Group)
capabilities = m.ManyToMany(Capability)
class Capability(m.Model):
name = m.CharField(...)
You don't need to wrap your parameters in Q() objects, you can use the key/value pairs directly:
widgets = Widget.objects.filter(
owner__memberships = current_user,
owner__memberships__memberships__capabilities__name = "widget_list"
)