Skip to content

Conversation

@lolrobbe2
Copy link
Contributor

@lolrobbe2 lolrobbe2 commented Oct 7, 2024

What does this PR do?

Add support for setting .NET sdk using dotnetsdk option. (only on new format projects otherwise just use the defautl)

Web
Razor
Worker
Blazor (BlazorWebAssembly)
WindowsDesktop
default (Microsoft.NET.Sdk)

How does this PR change Premake's behavior?

adds a new option called dotnetsdk

Anything else we should know?

Add any other context about your changes here.

Did you check all the boxes?

  • Focus on a single fix or feature; remove any unrelated formatting or code changes
  • Add unit tests showing fix or feature works; all tests pass
  • Mention any related issues (put closes #XXXX in comment to auto-close issue when PR is merged)
  • Follow our coding conventions
  • Minimize the number of commits
  • Align documentation to your changes

You can now support Premake on our OpenCollective. Your contributions help us spend more time responding to requests like these!

for some reason it took the commits from my previous pr (add C# documentation file to) i didn't change these files tho!

closes #2288

robbe beernaert and others added 30 commits June 29, 2023 17:49
(functional result stays the same)
@Jarod42
Copy link
Contributor

Jarod42 commented Nov 25, 2024

Tests failed:

[ FAILED ] vstudio_cs2005_dotnetsdk.testBlazorVersion
/home/runner/work/premake-core/premake-core/src/base/api.lua:646: attempt to index a nil value (local 'value')

@lolrobbe2
Copy link
Contributor Author

lolrobbe2 commented Nov 25, 2024

that is the issue for some reason the value is nill

image

@lolrobbe2 lolrobbe2 requested review from Jarod42 and tritao November 25, 2024 11:10
Co-authored-by: Joris Dauphin <[email protected]>
@nickclark2016
Copy link
Member

Can you resolve the merge conflict?

@lolrobbe2
Copy link
Contributor Author

lolrobbe2 commented Jan 3, 2025

update: i think the issue is with the fact that it does not do dictionary values:
@samsinsane, @tritao

so the solution would probaly be to have a portion where it handles the dictionary values because if i looked it up right ipairs only returns the indexed pairs

api.register snippet in _preload

	p.api.register {
		name = "dotnetsdk",
		scope = "project",
		kind = "string",
		allowed = {
			"Default",
			"Web",
			"Razor",
			"Worker",
			"Blazor",
			"WindowsDesktop",
			"MSTest",
			dynamicValidator = function (value)
				-- value is expected to be in the format <sdk>/<version>
				local parts = value:explode("/", true, 1)
				local sdk = parts[1] or value


				if parts and #parts == 2 then
					if p.api.checkValue(p.field.get("dotnetsdk"), parts[1], "string") then
						return value
					end
				end

				return nil
			end
		}
	}

api.register snippet:

for i, item in ipairs(field.allowed) do
    if type(item) == "string" then
         field.allowed[item:lower()] = item
    end	
end

api.addAllowed

function api.addAllowed(fieldName, value)
		local field = p.field.get(fieldName)
		if not field then
			error("No such field: " .. fieldName, 2)
		end

		if type(value) == "table" then
			for i, item in ipairs(value) do
				api.addAllowed(fieldName, item)
			end
		else
			field.allowed = field.allowed or {}

			-- If we are trying to add where the current value is a function,
			-- put the function in a table
			if type(field.allowed) == "function" then
				field.allowed = { field.allowed }
			end

			if field.allowed[value:lower()] == nil then
				table.insert(field.allowed, value)
				field.allowed[value:lower()] = value
			end
		end
	end

Copy link
Member

@samsinsane samsinsane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still outstanding changes requested from previous reviews.

@lolrobbe2
Copy link
Contributor Author

all outstanding changes should be fixed.

@lolrobbe2 lolrobbe2 requested a review from samsinsane January 6, 2025 11:41
@lolrobbe2
Copy link
Contributor Author

There are still outstanding changes requested from previous reviews.

@samsinsane all outstanding changes should have been take care of.
Can you pls look over everthing pls?

@samsinsane samsinsane merged commit baa0e37 into premake:master Jan 10, 2025
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants