swift – Protocol with generic array-like property

I’m creating a protocol to abstract different models (hand-crafted, decodable, and thrift-generated) like so:

protocol FeedItemModeling {
    var text: String? { get }
    var url: URL? { get }
}

protocol FeedModeling {
    var items: (FeedItemModeling)? { get }
}

This would work great except that thrift models aren’t using a basic array, but a TList which conforms to RandomAccessCollection among other things. Since both Array and Tlist conform to RandomAccessCollection, I’m trying to change the protocol definition to:

Attempt A)

var items: RandomAccessCollection<FeedItemModeling>? { get }

which gives the error: “Cannot specialize non-generic type ‘RandomAccessCollection’.” I assume it’s because associatedtype is a half-baked generics in the sense that it can enforce constraints internally in the protocol itself, but isn’t exposed externally; meaning that in our case, RandomAccessCollection‘s associatedtypes are resolved within RandomAccessCollection but there’s no way for FeedModeling to access it?

Attempt B)

var items: RandomAccessCollection? { get }

gives “Protocol ‘RandomAccessCollection’ can only be used as a generic constraint because it has Self or associated type requirements” and loses the constraint on FeedItemModeling anyway.

Attempt C)

associatedtype C: RandomAccessCollection
var items: C? { get }

works, but we lost the constraint on FeedItemModeling, so that’s not acceptable.

Attempt D)

associatedtype C: RandomAccessCollection
var items: C<FeedItemModeling>? { get }

gives “Cannot specialize non-generic type ‘Self.C’.” I assume it’s for the same reason as above?

Attempt E)

associatedtype C<E>: RandomAccessCollection where E: FeedItemModeling
var items: C? { get }

gives “Associated types must not have a generic parameter list”. I assume it’s because now there’s a constraint on a constraint, which can’t be expressed this way?

Attempt F)

typealias C<E> = RandomAccessCollection
var items: C<FeedItemModeling>? { get }

gives: “Protocol ‘RandomAccessCollection’ can only be used as a generic constraint because it has Self or associated type requirements”. Same reason?

Attempt G)

associatedtype FeedItemModelingList = RandomAccessCollection where RandomAccessCollection.Element: FeedItemModeling
var items: FeedItemModelingList? { get }

gives “Associated type ‘Element’ can only be used with a concrete type or generic parameter base”. I don’t understand this one; please let me know why?

Attempt H)

protocol FeedItemModelingList: RandomAccessCollection {}
...
var items: FeedItemModelingList? { get }

gives: “Protocol ‘FeedItemModelingList’ can only be used as a generic constraint because it has Self or associated type requirements”.

Attempt I)

protocol FeedItemModelingList: RandomAccessCollection where Element == FeedItemModeling {}
...
associatedtype L = FeedItemModelingList
var items: L? { get }

seems to work (so far), but is really a clusterf*. Any better idea?

Recibo el siguiente error: ERROR TypeError: Cannot read property ‘split’ of undefined al momento de ejecutar mi app en angular

import { Pipe, PipeTransform } from ‘@angular/core’;
import { Habilidades } from ‘../model/habilidades’;

@Pipe({
name: ‘cambiar’
})
export class CambiarPipe implements PipeTransform {

habilidad = new Habilidades();

transform(value: string): string {

let palabra;

var datos =  this.habilidad.titulo;
palabra = datos.split("",2);

for (const p in palabra){
 
value = value + p(0) 

}

return value;

}

}

c# – Representing a property with a non-nullable getter & a nullable setter

I have a class as follows, where I want the user of the class to know that setting the Slug property to null is supported, and its getter will still return a valid value:

public class Post
{
    public string Title { get; }
    public Post(string title)
    {
        Title = title;
    }

    private string? slug;
    public string Slug 
    { 
        get
        {
            if(slug is null)
            {
                slug = Title.Slugify();
            }
            return slug;
        }
        set => slug = value;
    }
}

There are two possible cases here:

CASE 1: No slug is set on/after initialization OR the slug is initialized with a non-null string.

var post = new Post("foo bar");
var slug = post.Slug;               // foo-bar

var post2 = new Post("foo bar 2") { Slug = "foo-bar-2" };
var slug2 = post.Slug;              // foo-bar-2

CASE 2: The slug set on is initialization with a nullable string.

string? maybeNull = viewModel.Slug; // may or may not be null
var post = new Post("foo bar") { Slug = maybeNull! };
var slug = post.Slug;               // returns an expected value

Is there a better way to do this, than using the null forgiving operator? The above code looks worse if I had to set it to null:

var post = new Post("foo bar") { Slug = null! };
var slug = post.Slug;               // returns an expected value

The reason I dont want to use the null forgiving operator is because it requires the user of the Post class to know that a null value can be safely passed into its Slug property — something I wish to avoid.

If it’s not possible to have different nullability for getters and setters (appears to me like it’s not), what is the best way to communicate my intent (users can safely set Slug to null + users will always get a valid slug, irrespective of what was set).

For some more context:

  • the Post class is instantiated with a nullable value only while creating a Post. Every other time, it’s going to be pulled from a database, and so will always be instantiated with a valid slug.
  • the Post class is not a ORM model.

web part – Managed Property not appearing in webpart

I have created a list in a SharePoint Communication site. The list was populated and has several columns to describe the information. The columns appear as crawled properties (ows_XXXXX). What I did was go into Site Settings > Site Collection Administration > Search Schema and mapped the crawled properties to RefinableStringXX. I have reindexed the site as well as reindexed the list. However, when I use SPfx Modern Search Webpart, I cannot see the RefinableStrings. If I use a standard webpart, I cannot see them either. I have also manually typed the name of the RefinableString into the webpart and nothing shows up. It’s been over a week since I have done the reindexing. Is there something I am missing?

sharepoint online – Property ‘selectedOptions’,’selectedIndex’,’options’ does not exist on type ‘HTMLElement’

I am working around with typescript in Sharepoint framework using No javascript approach. To get the dropdown text I am using the below code but it is not working:

var dept = (<HTMLElement>document.getElementById("ddlDepartment").selectedOptions(0).text)
OR

var empDeptt = document.getElementById("ddlDepartment")("value")

var selectedText = empDeptt.options(empDeptt.selectedIndex).text

Please suggest any workaround…..

dnd 3.5e – Is there a way to discern if the magic of an item is a “trap” or a “property” of the item?

With just detect magic and non-epic Spellcraft, the DM is correct. Detect magic can, at best, tell you what school of magic is involved in the making of an item—but curses and traps can be made from any school of magic, so that doesn’t really help you.

Technically, a Spellcraft check of 50 + the item’s caster level functions as identify, but that’s not something you’re likely to be able to pull off. (Remember, natural-20s are not automatic successes on skill checks.)

There is an item in Magic Item Compendium, the artificer’s monocle, which basically allows you to cast detect magic and get the effects of identify instead, without needing identify’s costly component. At 1,500 gp, it’s a pretty worthwhile item.

Also, cloistered clerics get identify as a 1st-level divine spell—and as a divine spell, identify doesn’t require arcane material components. Since a single level of cloistered cleric can be very useful to a lot of characters, but the spellcasting of a 1st-level cleric isn’t all that impressive (once you are a few levels above that yourself, anyway), it’s common for characters who dip cloistered cleric for the domains to fill their spell slots with identify, just because it’s convenient.

xamarin – How to initialise a bindable property of type Array from XAML

In a custom component, I define a bindable property of ARRAY type:

public static BindableProperty LabelsProperty = BindableProperty.Create(nameof(LabelStrings), typeof(string()), typeof(BLSelector), null, BindingMode.Default, propertyChanged: OnLabelsPropertyChanged);
public string() LabelStrings
{
    get => (string())GetValue(LabelsProperty);
    set => SetValue(LabelsProperty, value);
}
private static void OnLabelsPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
    var current = bindable as BLSelector;

    // Check the number of strings
    if (current.Commands != null && current.LabelStrings.Count() != current.Commands.Count())
    {
        Debug.WriteLine("Component::BLSelector - Bad number of Labels");
        throw new TargetParameterCountException();
    }

    // Updates the number of Label Controls
    current.LabelControls = new Label(current.LabelStrings.Count());

    // Set up the layout
    current.GridContendUpdate();
}

I would like to initialise this property from my XAML file like this :

        <components:BLSelector HorizontalOptions="CenterAndExpand"
                               TextColor="{StaticResource PrimaryTextColor}"
                               ItemBackgroundColor="{StaticResource PageBackgroundColor}" SelectedItemBackgroundColor="Beige"
                               Margin="10">
            <components:BLSelector.LabelStrings>
                <x:Array Type="{x:Type x:String}">
                    <x:String>"           Activités            "</x:String>
                    <x:String>"          Prestations           "</x:String>
                </x:Array>
            </components:BLSelector.LabelStrings>
        </components:BLSelector>

The app crashes without message (probably due to a null reference) when I launch it. If a put a breakpoint on the setter, I can see that it is never called.
BUT … If I add one “internal” initialisation in the constructor like the folowing, the setter is callled two times (which is normal) and the app do not crash.

public BLSelector()
{
    InitializeComponent();

    LabelStrings = new string(2){ "Test 1", "Test 2" };
}

What is the real type of array in XAML ? Is there an initialisation problem ? Any idea ?

Thanks a lot for your suggestions

JavaScript runtime error: Unable to get property '_injectGrid' of undefined or null reference

Grid is not loading on upgrading jquery from 1.8.3 to 3.5.1 Failing with the error just before loading grid :: JavaScript runtime error: Unable to get property '_injectGrid' of undefined or null reference.
Require some help on getting this resolved. Tried using jquery,migrate as well but it did not work

sharepoint online – Add Hyperlink at property pane description area

I am building an SPFX web-part and I want to put my company URL in the description of the property pane, like in the Microsoft docs snippet:

https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/basics/integrate-with-property-pane

But I cant find the way to do this and I googled for hours. Description always return the string and not the link.

Code below (already tried to override the description property to assume HTML but without success:

protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
return {
  pages: (
    {
      header: {
        description: strings.PropertyPaneDescription
      },
      displayGroupsAsAccordion: true,
      groups: (
        
        {
          groupName: strings.BasicGroupName,
          isCollapsed: true,
          groupFields: (
            PropertyPaneTextField('siteurl', {
              label: strings.SiteUrl
            }),
            PropertyPaneTextField('listname', {
              label: strings.List
            })

          )
        },
        {
          groupName: strings.NewsDefinitions,
          isCollapsed: true,
          groupFields: (
            PropertyPaneTextField('iconText', {
              label: strings.IconText
            }),
            PropertyPaneSlider('sliderproperty', {
              label: strings.Speed,
              min: 5,
              max: 60,
              value: 60,
              showValue: true,
              step: 1
            }),

          )

        },
        {
          groupName: strings.ColorDefinitions,
          isCollapsed: true,
          groupFields: (
            PropertyFieldColorPicker('iconTextColor', {
              label: strings.IconTextColor,
              selectedColor: this.properties.iconTextColor,
              onPropertyChange: this.onPropertyPaneFieldChanged,
              properties: this.properties,
              disabled: false,
              isHidden: false,
              alphaSliderHidden: false,
              style: PropertyFieldColorPickerStyle.Full,
              iconName: 'Precipitation',
              key: 'colorFieldId'
            }),

            PropertyFieldColorPicker('mainColor', {
              label: strings.MainColor,
              selectedColor: this.properties.mainColor,
              onPropertyChange: this.onPropertyPaneFieldChanged,
              properties: this.properties,
              disabled: false,
              isHidden: false,
              alphaSliderHidden: false,
              style: PropertyFieldColorPickerStyle.Full,
              iconName: 'Precipitation',
              key: 'colorFieldId'
            }),
            PropertyFieldColorPicker('innerColor', {
              label: strings.InnerColor,
              selectedColor: this.properties.innerColor,
              onPropertyChange: this.onPropertyPaneFieldChanged,
              properties: this.properties,
              disabled: false,
              isHidden: false,
              alphaSliderHidden: false,
              style: PropertyFieldColorPickerStyle.Full,
              iconName: 'Precipitation',
              key: 'innercolorFieldId'
            })
          )
        },
        {
          isCollapsed:false,
          groupFields: (
            PropertyFieldLinkWithCallout('fakeProp', {
              calloutTrigger: CalloutTriggers.Click,
              key: 'linkWithCalloutFieldId',
              calloutContent: React.createElement('p', {}, 'Click the link to open a new page with Application Terms & Conditions'),
              calloutWidth: 200,
              text: 'Terms & Conditions',
              href: 'https://github.com/pnp/sp-dev-fx-property-controls',
              target: '_blank'
            })
          )
        }
      )
    }
  )
};

}

enter image description here