Giter Club home page Giter Club logo

netstandard.windowsce's Introduction

NETStandard.WindowsCE

Nuget version (NETStandard.WindowsCE)

A library that implements the API of .NET Standard specification on Microsoft Windows CE platform.

Getting Started

Install the NuGet package

How existing classes are extended

The naming of classes that extends existing types are the same but appended '2' digit, as Activator2 and Int322. Instance methods are implemented using extension methods and class methods as static method.

using System;

// Lesser disruptive way for a code that needs to be compatible
// with multiple platforms
#if !WindowsCE
using static System.Int32;
#else
using static System.Int322;
#endif

namespace Tests
{
    static class Program
    {
        static void Main(string[])
        {
            int result;
            // Calls System.Int322.TryParse for Windows CE platforms
            // or calls System.Int32.TryParse for others
            if (!TryParse("123", NumberStyles.None, null, out result))
                System.Console.WriteLine("Could not parse provided string");
            else
                System.Console.WriteLine("The provided string could be parsed");
            
            const string text = "Lorem ipsum dolor sit amet";
            string croppedText = text.Remove(11);	// <-- Extension method
            System.Console.WriteLine("The text after processing: {0}", croppedText);
        }
    }
}

How not supported API are marked

The API that is not supported on Microsoft Windows CE platform throw PlatformNotSupportedException exception when called and are marked as deprecated using ObsoleteAttribute attribute.

VS showing deprecated message for not supported API

netstandard.windowsce's People

Contributors

gickis avatar skarllot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

netstandard.windowsce's Issues

Create Interlocked missing methods

Create missing methods of Interlocked class.

  • Read = Interlocked.CompareExchange(ref value, 0, 0).
  • MemoryBarrier = Thread.MemoryBarrier().

Detect canceled task for lazily initialized Task

The current implementation of AsyncTaskMethodBuilder does not check whether the Task is being canceled when the Task is not initialized.

if (task == null)
{
_task = new Task(exception);
return;
}
var cancelException = exception as InternalOCE;
bool setException;
if (cancelException != null)
setException = task.TrySetCanceled(cancelException.CancellationToken);
else
setException = task.TrySetException(exception);

Task Wait throwing exception

The method Wait of the class Task is throwing an exception when called.

   at System.Threading.Monitor.Exit(Object obj)
   at System.Threading.Monitor2.ReleaseAll(Object obj)
   at System.Threading.Condition.Wait(Int32 millisecondsTimeout)
   at System.Threading.Monitor2.Wait(Object obj, Int32 millisecondsTimeout)
   at System.Threading.ManualResetEventSlim.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at System.Threading.Tasks.Task.<>c__DisplayClass119_0`1.<Run>b__0()
   at System.Threading.Tasks.Task`1.ExecuteTaskAction()
   at System.Threading.Tasks.Task.TaskStartAction(Object stateObject)
   at System.Threading.ThreadPool.WorkItem.doWork(Object o)
   at System.Threading.Timer.ring()

Support conversion to IReadOnlyCollection and IReadOnlyList

Support conversion to IReadOnlyCollection and IReadOnlyList from Array, List, ICollection and others.

// The following code should work
IReadOnlyCollection<byte> value1 = (new byte[] { 15, 7, 4 }).AsReadOnly();
IReadOnlyList<byte> value2 = (new byte[] { 15, 7, 4 }).AsReadOnly();
IReadOnlyList<byte> value3 = new List<byte>(new byte[] { 15, 7, 4 }).AsReadOnlyList();

System.Task fires completed signal before getting its result

Tried to partial implementation of Tasks, in particular waited for task to complete within timeout. Had graceful completion but default task result.

STR:
Run sample on Windows CE

ER:
To get the graceful result(123) and no timeouts.

AR:
No timeouts, but default result

See sample below.

using System;
using System.Threading;
using System.Threading.Tasks;
using Task = System.Threading.Tasks.Task;

namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var runningTask = CalculateSomething();
            var result = Execute(runningTask, TimeSpan.FromSeconds(10));//succeeds but result is 0, not 123 in Execute and Execute1 methods

            Console.WriteLine(result);
            Console.ReadLine();
        }

        private static async Task<int> CalculateSomething()
        {
            Console.WriteLine("Calculating....");
            await Task.Delay(TimeSpan.FromSeconds(5));
            Console.WriteLine("Done");

            return 123;
        }

        private static T Execute<T>(Task<T> task, TimeSpan timeout)
        {
            if (task.Wait(timeout))
            {
                Console.WriteLine("Got graceful result");
                return task.Result;
            }

            Console.WriteLine("Timeout");
            return default(T);
        }

        private static T Execute1<T>(Task<T> task, TimeSpan timeout)
        {
            var tcs = new CancellationTokenSource(timeout);

            var runningTask = Task.Run(() => task, tcs.Token);

            var result = runningTask.GetAwaiter().GetResult();

            return result;
        }
    }
}

was any update for Windows CE OS

my mean is OS.
Because Microsoft gave up Windows CE system update and support. The .net is crumbling in handheld devices. Android began to enter in large numbers, and java and kotlin began to eat market share. After all this is completely switched, what else can we do with .net?

Support Type.IsConstructedGenericType

Support the property IsConstructedGenericType from Type class.

public override bool IsConstructedGenericType 
{
    get { return IsGenericType && !IsGenericTypeDefinition; } 
} 

Extend Activator

Extend Activator2 class to allow access to private constructor.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.